Part Number Hot Search : 
UPD78F0 BZX85C36 74AHC GS816 BL431 ICL3221E SBL1630 DSP56603
Product Description
Full Text Search
 

To Download TMP93CS40 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 TOSHIBA Original CMOS 16-Bit Microcontroller
TLCS-900/L Series
TMP93CS40/41
Semiconductor Company
Preface
Thank you very much for making use of Toshiba microcomputer LSIs. Before use this LSI, refer the section, "Points of Note and Restrictions". Especially, take care below cautions.
**CAUTION** How to release the HALT mode Usually, interrupts can release all halts status. However, the interrupts = (NMI , INT0), which can release the HALT mode may not be able to do so if they are input during the period CPU is shifting to the HALT mode (for about 3 clocks of fFPH) with IDLE1 or STOP mode (IDLE2 and RUN are not applicable to this case). (In this case, an interrupt request is kept on hold internally.) If another interrupt is generated after it has shifted to HALT mode completely, halt status can be released without difficultly. The priority of this interrupt is compare with that of the interrupt kept on hold internally, and the interrupt with higher priority is handled first followed by the other interrupt.
TMP93CS40/TMP93CS41
Low Voltage/Low Power CMOS 16-Bit Microcontrollers
TMP93CS40F/TMP93CS41F TMP93CS40DF/TMP93CS41DF 1. Outline and Device Characteristics
The TMP93CS40/S41 are high-speed advanced 16-bit microcontrollers developed for controlling medium to large-scale equipment. The TMP93CS41 does not have a ROM; the TMP93CS40 has a built-in ROM. Otherwise, the devices function in the same way. The TMP93CS40/S41F are housed in a 100-pin flat package. The device characteristics are as follows: (1) Original 16-bit CPU (900/L CPU) * * * * * TLCS-90 instruction mnemonic upward compatible 16-Mbyte linear address space General-purpose registers, register bank system 16-bit multiplication/division and bit transfer/arithmetic instructions Micro DMA: 4 channels (1.6 s/2 bytes at 20 MHz)
(2) Minimum instruction execution time: 200 ns at 20 MHz (3) Internal RAM: 2 Kbytes Internal ROM:
TMP93CS40 TMP93CS41 64-Kbyte ROM None
(4) External memory expansion * * * Can be expanded up to 16 Mbytes (for both programs and data). AM8/ 16 pin (selects the external data bus width) Can mix 8-/16-bit external data buses. ..... Dynamic bus sizing
(5) 8-bit timer: 2 channels
030619EBP1
* The information contained herein is subject to change without notice. * The information contained herein is presented only as a guide for the applications of our products. No responsibility is assumed by TOSHIBA for any infringements of patents or other rights of the third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of TOSHIBA or others. * TOSHIBA is continually working to improve the quality and reliability of its products. Nevertheless, semiconductor devices in general can malfunction or fail due to their inherent electrical sensitivity and vulnerability to physical stress. It is the responsibility of the buyer, when utilizing TOSHIBA products, to comply with the standards of safety in making a safe design for the entire system, and to avoid situations in which a malfunction or failure of such TOSHIBA products could cause loss of human life, bodily injury or damage to property. In developing your designs, please ensure that TOSHIBA products are used within specified operating ranges as set forth in the most recent TOSHIBA products specifications. Also, please keep in mind the precautions and conditions set forth in the "Handling Guide for Semiconductor Devices," or "TOSHIBA Semiconductor Reliability Handbook" etc.. * The TOSHIBA products listed in this document are intended for usage in general electronics applications (computer, personal equipment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). These TOSHIBA products are neither intended nor warranted for usage in equipment that requires extraordinarily high quality and/or reliability or a malfunctionor failure of which may cause loss of human life or bodily injury ("Unintended Usage"). Unintended Usage include atomic energy control instruments, airplane or spaceship instruments, transportation instruments, traffic signal instruments, combustion control instruments, medical instruments, all types of safety devices, etc.. Unintended Usage of TOSHIBA products listed in this document shall be made at the customer's own risk. * The products described in this document are subject to the foreign exchange and foreign trade laws. * TOSHIBA products should not be embedded to the downstream products which are prohibited to be produced and sold, under any law and regulations. * For a discussion of how the reliability of microcontrollers can be predicted, please refer to Section 1.3 of the chapter entitled Quality and Reliability Assurance/Handling Precautions.
93CS40-1
2004-02-10
TMP93CS40/TMP93CS41
(6) 8-bit PWM timer: 2 channels (7) 16-bit timer: 2 channels (8) 4-bit pattern generator: 2 channels (9) Serial interface: 2 channels (10) 10-bit AD converter: 8 channels (11) Watchdog timer (12) Chip select/wait controller: 3 blocks (13) Interrupt functions: 29 * * * 9 CPU interrupts .... SWI instruction, and illegal instruction 14 internal interrupts 6 external interrupts 7-level priority can be set.
(14) I/O ports 79 pins for TMP93CS40 and 61 pins for TMP93CS41 (15) Standby function: 4 HALT modes (RUN, IDLE2, IDLE1, STOP) (16) Clock gear function * * * Dual clock operation Clock gear: High-frequency clock can be varied from fc to fc/16. Vcc = 2.7 to 5.5 V
(17) Wide operating voltage (18) Package Type No.
TMP93CS40F TMP93CS41F TMP93CS40DF TMP93CS41DF
Package
P-QFP100-1414-0.50 P-LQFP100-1414-0.50F
93CS40-2
2004-02-10
TMP93CS40/TMP93CS41
PA0 to PA6 PA7 (SCOUT)
Port A
900/L CPU
VCC [3] VSS [3] Highfrequency OSC X1 X2 CLK Lowfrequency OSC XT1 XT2 AM8/ AM16
EA
RESET
P50 to P57 (AN0 to AN7) AVCC AVSS VREFH VREFL
10-bit 8-ch AD converter
XWA XBC XDE XHL XIX XIY XIZ XSP
WA
BC DE HL IX IY IZ SP 32 bits SR F PC
(TXD0) P90 (RXD0) P91 (SCLK0/ CTS0 ) P92 (TXD1) P93 (RXD1) P94 (SCLK1) P95
Serial I/O (Channel 0) Serial I/O (Channel 1)
ALE TEST1 TEST2 Interrupt controller P87 (INT0)
NMI
(PG00) P60 (PG01) P61 (PG02) P62 (PG03) P63 (PG10) P64 (PG11) P65 (PG12) P66 (PG13) P67
Pattern generator (Channel 0) Pattern generator (Channel 1) 2-Kbyte RAM
Watchdog timer
WDTOUT
Port 0
P00 to P07 (AD0 to AD7)
(TI0) P70
8-bit timer (Timer 0) 8-bit timer (Timer 1)
Port 1
P10 to P17 (AD8 to AD15/A8 to A15)
(TO1) P71
Port 2
P20 to P27 (A0 to A7/A16 to A23)
(TO2) P72
8-bit PWM (Timer 2) 64-Kbyte ROM 8-bit PWM (Timer 3)
P30 ( RD ) P31 ( WR ) P32 ( HWR ) Port 3 P33 ( WAIT ) P34 ( BUSRQ
(TO3) P73
)
P35 ( BUSAK ) (INT4/TI4) P80 (INT5/TI5) P81 (TO4) P82 (TO5) P83 (INT6/TI6) P84 (INT7/TI7) P85 (TO6) P86 16-bit timer (Timer 4) 16-bit timer (Timer 5) (Not included on the TMP93CS41)
CS/WAIT controller (3 blocks)
P36 ( R/ W )
P37 ( RAS ) P40 ( CS0 / CAS0 ) P41 ( CS1 / CAS1 ) P42 ( CS2 / CAS2 )
Figure 1.1 TMP93CS40/TMP93CS41 Block Diagram
93CS40-3
2004-02-10
TMP93CS40/TMP93CS41
2.
Pin Assignment and Functions
The assignment of input/output pins on the TMP93CS40/TMP93CS41, their names and outline functions are described below.
2.1
Pin Assignment
Figure 2.1.1 shows the pin assignment for the TMP93CS40F/S41F and TMP93CS40DF/S41DF.

88 P65/PG11 P66/PG12 P67/PG13 VSS P50/AN0 P51/AN1 P52/AN2 P53/AN3 P54/AN4 P55/AN5 P56/AN6 P57/AN7 VREFH VREFL AVSS AVCC
NMI
89 90 91 92 93 94 95 96 97 98 99 100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
87 P64/PG10 86 P63/PG03 85 P62/PG02 84 P61/PG01 83 P60/PG00 82 P42/ CS2 / CAS2 81 P41/ CS1 / CAS1 80 P40/ CS0 / CAS0 79 P37/ RAS 78 P36/ R / W 77 P35/ BUSAK 76 P34/ BUSRQ 75 P33/ WAIT 74 P32/ HWR 73 P31/ WR 72 P30/ RD 71 P27/A7/A23 70 P26/A6/A22 69 P25/A5/A21 68 P24/A4/A20 67 P23/A3/A19 66 P22/A2/A18

ADC
SIO

P70/TI0 P71/TO1 P72/TO2 P73/TO3 P80/INT4/TI4 P81/INT5/TI5 P82/TO4 P83/TO5 P84/INT6/TI6 P85/INT7/TI7 P86/TO6 P87/INT0 P90/TXD0 P91/RXD0 P93/TXD1 P94/RXD1 P95/SCLK1 AM8/ AM16 CLK VCC VSS
Timer
Top view QFP100 (LQFP100)
65 64 63 62 60 59 58 57 56 55 54
P21/A1/A17 P20/A0/A16 VCC VSS P17/AD15/A15 P16/AD14/A14 P15/AD13/A13 P14/AD12/A12 P13/AD11/A11 P12/AD10/A10 P11/AD9/A9
61 WDTOUT
P92/ CTS0 /SCLK0 19
53 P10/AD8/A8 52 P07/AD7 51 P06/AD6 50 P05/AD5 49 P04/AD4 48 P03/AD3 47 P02/AD2 46 P01/AD1 45 P00/AD0 44 VCC 43 ALE 42 PA7/SCOUT 41 PA6 40 PA5 39 PA4 38 PA3
Clock mode
X1 X2
EA RESET
P96/XT1 P97/XT2 TEST1 TEST2 PA0 PA1 PA2
Note: Because the TMP93CS41 does not have an internal ROM, pins P00 to P17 are tied to AD0 to AD15 (when AM8/ AM16 = 0), or to AD0 to AD7 and A8 to A15 (when AM8/ AM16 = 1). P30 is tied to RD , P31 to WR . Figure 2.1.1 Pin Assignment (100-Pin QFP and 100-Pin LQFP)
93CS40-4
2004-02-10
Memory interface
Stepping motor control
Programmable Pull Pull up down
TMP93CS40
Pin no.
Pin no.
TMP93CS40
Programmable Pull Pull down up
TMP93CS40/TMP93CS41
2.2
Pin Names and Functions
The names of the input/output pins and their functions are described below. Table 2.2.1 to Table 2.2.4 show pin names and functions. Table 2.2.1 Pin Names and Functions (1/4)
Pin Names
P00 to P07 AD0 to AD7 P10 to P17 AD8 to AD15 A8 to A15 P20 to P27 A0 to A7 A16 to A23 P30
RD
Number of Pins
8 8
I/O
I/O Tri-state I/O Tri-state Output I/O Output Output
Functions
Port 0: I/O port that allows at the bit level Address/data (lower): Bits 0 to 7 of address/data bus Port 1: I/O port that allows at the bit level Address data (upper): Bits 8 to 15 of address/data bus Address: Bits 8 to 15 of address bus Port 2: I/O port that allows selection of I/O at the bit level (with pull-down resistor) Address: bits 0 to 7 of address bus Address: bits 16 to 23 of address bus Port 30: Output port Read: Strobe signal for reading external memory Port 31: Output port Write: Strobe signal for writing data on pins AD0 to AD7 Port 32: I/O port (with pull-up resistor) High write: Strobe signal for writing data on pins AD8 to AD15 Port 33: I/O port (with pull-up resistor) Wait: in used to request CPU bus wait Port 34: I/O port (with pull-up resistor) Bus request: Signal used to request bus release Port 35: I/O port (with pull-up resistor) Bus acknowledge: Signal used to acknowledge bus release
Port 36: I/O port (with pull-up resistor) Read/write: 1 represents read or dummy cycle; 0 represents write cycle. Port 37: I/O port (with pull-up resistor) Row address strobe: Outputs RAS strobe for DRAM. Port 40: I/O port (with pull-up resistor) Chip select 0: Outputs 0 when address is within specified address area. Column address strobe 0: Outputs CAS strobe for DRAM when address is within specified address area.
8
1 1 1 1 1 1
1 1 1
Output Output Output Output I/O Output I/O Input I/O Input I/O Output
I/O Output I/O Output I/O Output Output
P31
WR
P32
HWR
P33
WAIT
P34
BUSRQ
P35
BUSAK
P36 R/ W
P37
RAS
P40
CS0 CAS0
Note: This device's built-in memory or built-in I/O cannot be accessed by an external DMA controller using the BUSRQ and BUSAK signals.
93CS40-5
2004-02-10
TMP93CS40/TMP93CS41
Table 2.2.2 Pin Names and Functions (2/4) Pin Names
P41
CS1 CAS1
Number of Pins
1
I/O
I/O Output Output
Functions
Port 41: I/O port (with pull-up resistor) Chip select 1: Outputs 0 if address is within specified address area. Column address strobe 1: Outputs CAS strobe for DRAM if address is within specified address area. Port 42: I/O port (with pull-down resistor) Chip select 2: Outputs 0 if address is within specified address area. Column address strobe 2: Outputs CAS strobe for DRAM if address is within specified address area. Port 5: Input port Analog input: Analog signal input for AD converter Pin for high level reference voltage input to AD converter Pin for low level reference voltage input to AD converter Ports 60 to 63: I/O ports that allow selection of I/O at the bit level (with pull-up resistor) Pattern generator ports: 00 to 03 Ports 64 to 67: I/O ports that allow selection of I/O on a bit basis (with pull-up resistor) Pattern generator ports: 10 to 13 Port 70: I/O port (with pull-up resistor) Timer input 0: Timer 0 input Port 71: I/O port (with pull-up resistor) Timer output 1: Timer 0 or timer 1 output Port 72: I/O port (with pull-up resistor) PWM output 2: 8-bit PWM timer 2 output Port 73: I/O port (with pull-up resistor) PWM output 3: 8-bit PWM timer 3 output Port 80: I/O port (with pull-up resistor) Timer input 4: Timer 4 count/capture trigger signal input Interrupt request pin 4: Interrupt request pin with programmable rising/falling edge Port 81: I/O port (with pull-up resistor) Timer input 5: Timer 5 count/capture trigger signal input Interrupt request pin 5: Interrupt request pin with rising edge Port 82: I/O port (with pull-up resistor) Timer output 4: Timer 4 output pin Port 83: I/O port (with pull-up resistor) Timer output 5: Timer 4 output pin
P42
CS2 CAS2
1
I/O Output Output
P50 to P57 AN0 to AN7 VREFH VREFL P60 to P63 PG00 to PG03 P64 to P67 PG10 to PG13 P70 TI0 P71 TO1 P72 TO2 P73 TO3 P80 TI4 INT4 P81 TI5 INT5 P82 TO4 P83 TO5
8 1 1 4
Input Input Input Input I/O Output
4
I/O Output
1 1 1 1 1
I/O Input I/O Output I/O Output I/O Output I/O Input Input
1
I/O Input Input
1 1
I/O Output I/O Output
93CS40-6
2004-02-10
TMP93CS40/TMP93CS41
Table 2.2.3 Pin Names and Functions (3/4) Pin Names
P84 TI6 INT6 P85 TI7 INT7 P86 TO6 P87 INT0 P90 TXD0 P91 RXD0 P92
CTS0
Number of Pins
1
I/O
I/O Input Input
Functions
Port 84: I/O port (with pull-up resistor) Timer input 6: Timer 5 count/capture trigger signal input Interrupt request pin 6: Interrupt request pin with programmable rising/falling edge Port 85: I/O port (with pull-up resistor) Timer input 7: Timer 5 count/capture trigger signal input Interrupt request pin 7: Interrupt request pin with rising edge Port 86: I/O port (with pull-up resistor) Timer output 6: Timer 5 output pin Port 87: I/O port (with pull-up resistor) Interrupt request pin 0: Interrupt request pin with programmable level/rising edge Port 90: I/O port (with pull-up resistor) Serial data send 0 Port 91: I/O port (with pull-up resistor) Serial data receive 0 Port 92: I/O port (with pull-up resistor) Serial data send enable 0 (Clear to send) Serial Clock I/O 0 Port 93: I/O port (with pull-up resistor) Serial data send 1 Port 94: I/O port (with pull-up resistor) Serial data receive 1 Port 95: I/O port (with pull-up resistor) Serial clock I/O 1 Ports A0 to A6: I/O ports Port A7: I/O port System clock output: Outputs fFPH or fSYS clock. Watchdog timer output pin Non-maskable interrupt request pin: Interrupt request pin with programmable falling edge or with both edges programmable. Clock output: Outputs [fSYS / 2] clock. Pulled-up during reset. Can be disabled to reduce noise.
1
I/O Input Input
1 1 1 1 1
I/O Output I/O Input I/O Output I/O Input I/O Input I/O
SCLK0 P93 TXD1 P94 RXD1 P95 SCLK1 PA0 to PA6 PA7 SCOUT
WDTOUT NMI
1 1 1 7 1 1 1 1
I/O Output I/O Input I/O I/O I/O I/O Output Output Input Output
CLK
EA
1
Input
External access: On the TMP93CS41, the Vss pin should be connected. On the TMP93CS40, the Vcc pin should be connected.
93CS40-7
2004-02-10
TMP93CS40/TMP93CS41
Table 2.2.4 Pin Names and Functions (4/4) Pin Names
AM8/ AM16
Number of Pins
1
I/O
Input (On the TMP93CS40)
Functions
Address mode: Selects external data bus width. The Vcc pin should be connected. The data bus width for external access is set by the chip select/WAIT control register, port 1 control register. (On the TMP93CS41) The Vss pin should be connected to access either fixed 16-bit bus width, or 16-bit bus interchangeable with 8-bit bus. The Vcc pin should be connected to access a fixed 8-bit bus width.
ALE
RESET
1 1 2 1 1 2 3 3 1 1
Output Input I/O I/O Input I/O Output Output/Input
Address latch enable (Can be disabled to reduce noise.) Reset: Initializes TMP93CS40/TMP93CS41. (with pull-up resistor) High-frequency oscillator connecting pin Port 96: I/O port (open-drain output) Low-frequency oscillator connecting pin Port 97: I/O port (open drain output) Low-frequency oscillator connecting pin TEST1 pin should be connected to TEST2 pin. Don't connect to any other pins. Power supply pin (All VCC pins should be connected to the power supply pin.) GND pin (0 V) (All VSS pins should be connected to GND (0 V).) Power supply pin for AD converter GND pin for AD converter (0 V)
X1/X2 P96 XT1 P97 XT2 TEST1/TEST2 VCC VSS AVCC AVSS
Note:
All pins that have built-in pull-up/pull-down resistors (other than the RESET pin) can be disconnected from the built-in pull-up/pull-down resistor by software.
93CS40-8
2004-02-10
TMP93CS40/TMP93CS41
3.
Operation
This section describes in blocks the functions and basic operations of TMP93CS40 and TMP93CS41 devices. Please also refer to section 7. Precautions in use, which describes some points requiring careful attention.
3.1
CPU
TMP93CS40 and TMP93CS41 devices have a built-in high-performance 16-bit CPU (900/L CPU). (For basics of the CPU operation, see the information on the TLCS-900/L CPU in the previous chapter.) This section describes some CPU functions unique to the TMP93CS40 and TMP93CS41, that are not described in the previous chapter, entitled TLCS-900/L CPU.
3.1.1
Reset
When resetting the TMP93CS40 and TMP93CS41 microcontroller, ensure that the power supply voltage is within the operating voltage range, and that the internal high-frequency oscillator has stabilized. Then set the RESET input to low level at least for 10 system clocks (16 s at 20 MHz). Thus, when turn on the switch, be set to the power supply voltage is within the operating voltage range, and that the internal high-frequency oscillator has stabilized. Then hold the RESET input to low level at least for 10 system clocks. Clock gear is initialized 1/16 mode by reset operation. It means that the system clock mode fSYS is set to fc/32 (= fc/16 x 1/2). * When a reset signal is accepted, the CPU sets itself as follows: The program counter (PC) is set according to the reset vector that is stored from 8000H to 8002H. PC<7:0> Data in location 8000H PC<15:8> Data in location 8001H * * * * PC<23:16> Data in location 8002H The stack pointer (XSP) for system mode is set to 100H. The bits of the status register SR are set to 111. (Sets mask register to interrupt level 7.) The bit of SR is set to 1. (Sets to maximum mode. See previous chapter.)
The bits of SR are set to 000. (Clears register banks to 0.) When the reset is released, instruction execution starts from PC (The reset vector). The reset makes no changes in any CPU internal registers other than those specifically mentioned above. When a reset is received, signal and data processing for built-in I/Os, ports, and other pins is affected as follows: * Initializes built-in I/O registers as per specifications. * * * * Sets port pins (including pins also used as built-in I/Os) to general-purpose input/output port mode. Sets the WDTOUT pin to 0. (The watchdog timer is set to enable after reset.) Pulls up the CLK pin to 1. Sets the ALE pin to 0 in the case of the TMP93CS41, and to high impedance (High-Z) in the case of TMP93CS40.
Note 1: Resetting makes no change in any register in the CPU except the program counter (PC), status register (SR) and stack pointer (XSP), nor in the data in the internal RAM. Note 2: The CLK pin is pulled up during reset. When the voltage is externally reduced, there is a possibility of causing malfunctions. Figure 3.1.1 and Figure 3.1.2 show the reset timing chart of the TMP93CS41 and TMP93CS40.
93CS40-9
2004-02-10
45 X1 cycles omitted Total of 220 X1 cycles omitted
X1
Sampling Sampling (P20 to P27 input mode) (P40 to P41 input mode)
CLK
RESET
A16 to A23
CS0 to CS1 (P42 input mode) (P36 input mode)
CS2
R/W
ALE
Address Address Address Data input
AD0 to AD15
RD
Read
AD0 to AD15
Address Data output Address
(Starts read cycle of 2 waits after reset release) Write (P32 input mode) (P37 input mode) (P40 to P41 input mode) (P42 input mode) (Input mode) (Input mode) (Input mode) (Output mode: Open-drain output)
Figure 3.1.1 TMP93CS41 Reset Timing Chart
93CS40-10
WR
HWR
RAS
CAS0 to CAS1
CAS2
P20 to P27, P42
P32 to P37, P40 to P41 P60 to P67, P70 to P73 P80 to P87, P90 to P95
P50 to P57, PA0 to PA7
P96 to P97
TMP93CS40/TMP93CS41
2004-02-10
Internal pull up or pull down High impedance
45 X1 cycles omitted Total of 220 X1 cycles omitted
X1
Sampling Sampling (P20 to P27 input mode) (P40 to P41 input mode)
CLK
RESET
A16 to A23
CS0 to CS1 (P42 input mode) (P36 input mode)
CS2
R/W
ALE
Address Address
AD0 to AD15
Read
RD
Address Data output Address
AD0 to AD15
(Starts read cycle of 2 waits after reset release) Write (P32 input mode) (P37 input mode) (P40 to P41 input mode) (P42 input mode) (Input mode) (Input mode) (Input mode) (Output mode: Open-drain output)
Figure 3.1.2 TMP93CS40 Reset Timing Chart
93CS40-11
WR
HWR
RAS
CAS0 to CAS1
CAS2
P20 to P27, P42
P32 to P37, P40 to P41 P60 to P67, P70 to P73 P80 to P87, P90 to P95
P50 to P57, PA0 to PA7
P96 to P97
TMP93CS40/TMP93CS41
2004-02-10
Internal pull up or pull down High impedance
TMP93CS40/TMP93CS41 3.1.2 AM8/ AM16 Pin
(1) TMP93CS40 Set this pin to 1. Resetting accesses a built-in ROM via the internal 16-bit bus. When accessing externally, the bus width is set by the chip select/wait control register described in 3.6.3, and the registers of port 1. (2) TMP93CS41 1. With fixed 16-bit data bus or with 16-bit data bus interchangeable with 8-bit data bus. Set this pin to 0. Port 1, AD8 to AD15 or A8 to A15 pins are fixed to AD8 to AD15 functions. Any values set in the port 1 control register or the port 1 function register are invalid. The external data bus width is set by the chip select/wait control register. After reset, it is necessary to set the program memory to be accessed, to 16-bit data bus. With fixed external 8-bit data bus Set this pin to 1. Port 1, AD8 to AD15 or A8 to A15 pins are fixed to A8 to A15 functions. Any values set in the port 1 control register or the port 1 function register are invalid. The values of Bit4 , and in the chip select/wait control register, which are described in 3.6.2, are invalid. The external 8-bit data bus is fixed.
2.
93CS40-12
2004-02-10
TMP93CS40/TMP93CS41
3.2
Memory Map
Figure 3.2.1 is a memory map of the TMP93CS40 and TMP93CS41.
000000H Internal I/O (128 bytes) 000080H 256-byte direct area (n)
000100H Internal RAM (2 Kbytes) 000880H
External memory
64-Kbyte area (nn)
008000H 008100H
Interrupt vector table area (64 entries x 4 bytes)
010000H 64-Kbyte internal ROM (TMP93CS40) External memory area in TMP93CS41
018000H
External memory
16-Mbyte area (R) (-R) (R+) (R + R8/16) (R + d8/16) (nnn)
FFFF00H FFFFFFH
Reserved (256 bytes) ( = Internal area)
Note: The 256-byte area from FFFF00H to FFFFFFH can not be used. Figure 3.2.1 Memory Map
93CS40-13
2004-02-10
TMP93CS40/TMP93CS41
3.3
Dual Clock, Standby Function
Dual clock, standby control circuits are comprised of a system clock controller, prescaler clock controller, internal clock pin output function and standby controller. The oscillator operating modes are classified as either (a) Single clock mode (using only the X1 and X2 pins), or (b) Dual clock mode (using the X1, X2, XT1, and XT2 pins). Figure 3.3.1 shows state diagrams for the two clock modes. Figure 3.3.2 shows the corresponding block diagram, Figure 3.3.3 displays functions of the I/O registers and Table 3.3.1 lists correspondences between alternative states of the system clock and those of the CPU, oscillator and internal I/O components.
RESET
RUN mode (Stops only CPU) IDLE2 mode (Stops CPU and AD) IDLE1 mode (Operates only oscillator)
Instruction Interrupt Instruction Interrupt Instruction Interrupt
Release reset
NORMAL mode (fc/gear value/2)
Instruction Interrupt
STOP mode (Stops all circuits)
(a) Single Clock Mode State Diagram
RESET
RUN mode (Stops only CPU) IDLE2 mode (Stops CPU and AD) IDLE 1 mode (Operates only oscillator)
Instruction Interrupt Instruction Interrupt Instruction Interrupt
Release reset
NORMAL mode (fc/gear value/2)
Instruction
Instruction
Interrupt
STOP mode (Stops all circuits)
RUN mode (Stops only CPU) IDLE 2 mode (Stops CPU and AD) IDLE 1 mode (Operates only oscillator)
Instruction Interrupt Instruction Interrupt Instruction Interrupt
Instruction
SLOW mode (fs/2)
(b) Dual Clock Mode State Diagram Figure 3.3.1 State Diagrams The clock frequency input from the X1 and X2 pins is called fc, and the clock frequency input from the XT1 and XT2 pins is called fs. The clock frequency selected by SYSCR1 and is called the system clock fFPH. The divided clock of fFPH is defined as the system clock fSYS, and one cycle of fSYS is defined as one state.
93CS40-14
2004-02-10
TMP93CS40/TMP93CS41
Table 3.3.1 Relations between System Clock States and Other Internal Operations Operating Mode
RESET Single clock NORMAL RUN IDLE2 IDLE1 STOP RESET NORMAL Dual clock SLOW RUN IDLE2 IDLE1 STOP Oscillation Stop Stop Programmable Oscillation Stop only AD Stop Reset Oscillation Stop Stop
Oscillator High Low Frequency (fc) Frequency (fs) CPU
Reset Operate
Internal I/O
Reset Operate Stop only AD Stop Reset
System Clock fSYS
fc/32 Programmable (fc/2, fc/4, fc/8, fc/16, fc/32) Stop fc/32 Programmable (fc/2, fc/4, fc/8, fc/16, fc/32) fs/2 Programmable (fc/2, fc/4, fc/8, fc/16, fc/32, fs/2) Stop
Operate
Operate
Programmable
Oscillator being used as system clock: Oscillation Other oscillator: Programmable Stop
Stop
93CS40-15
2004-02-10
* Warm-up (Changing clocks) ... fc or fs. * Warm-up (Releasing STOP mode) ... fFPH SYSCR0 fc fs Warm-up timer Watchdog timer/ * Watchdog timer ... fSYS
8-bit pWMs 0 and 1 5-bit prescaler Run and stop TRUN fs fc/16 Selector /2 /4 9-bit prescaler 8-bit timers 0 and 1 16-bit timers 4 and 5 Serial interfaces 0 and 1
Figure 3.3.2 Block Diagram of Dual Clock and Standby Circuits
SYSCR0
93CS40-16
fFPH
System clock fSYS
Internal I/O ROM, RAM
SYSCR0 fs Selector
XT2
XT1
Low-frequency oscillator
/2
CPU
Selector
/2 Selector
CLK SCOUT/PA7
WDMOD
SYSCR1 SYSCR0
SYSCR0 SYSCR1
fc/2 fc/4 fc/8 fc/16
X2 /2 /4 /8 /16
TMP93CS40/TMP93CS41
2004-02-10
X1
High-frequency oscillator fc
CKOCR
TMP93CS40/TMP93CS41
7
SYSCR0 (006EH)
6
XTEN 0
Lowfrequency oscillator (fs) 0: Stop 1: Oscillation
5
RXEN 1
Highfrequency oscillator (fc) after released STOP mode 0: Stop 1: Oscillation
4
RXTEN R/W 0
Lowfrequency oscillator (fs) after released STOP mode 0: Stop 1: Oscillation
3
RSYSCK 0
Select clock after STOP mode is released 0: fc 1: fs
2
WUEF 0
Warm-up timer (Write) 0:Don't care 1: Start timer (Read) 0: Warm up complete 1: Continue warm up
1
PRCK1 0
00: fFPH 01: fs 10: fc/16 11: (Reserved)
0
PRCK0 0
Bit symbol Read/Write After reset Function
XEN 1
Highfrequency oscillator (fc) 0: Stop 1: Oscillation
Select prescaler clock
SYSCR1 (006FH)
Bit symbol Read/Write After reset Function
SYSCK 0 Select system clock 0: fc 1: fs
GEAR2 R/W
GEAR1
GEAR0
1 0 0 Select gear value of high frequency (fc) 000: fc 001: fc/2 010: fc/4 011: fc/8 100: fc/16 101: (Reserved) 110: (Reserved) 111: (Reserved) HALTM0 0 RESCR 0
1: Connects WDT output to reset pin internally.
WDMOD (005CH)
Bit symbol Read/Write After reset Function
WDTE 1
WDT control 1: Enable
WDTP1 0
WDTP0 0
WARM R/W 0
Warm-up timer 14 0: 2 / frequency input 16 1: 2 / frequency input
HALTM1 0
Standby mode 00: RUN mode 01: STOP mode 10: IDLE1 mode 11: IDLE mode
DRVE 0
1: Drives pin even in STOP mode
WDT detection time 00: 2 /fSYS 01: 2 /fSYS 10: 219/fSYS 11: 221/fSYS
17 15
CKOCR (006DH)
Bit symbol Read/Write After reset Function
SCOSE 0
SCOUT select 0: fFPH 1: fSYS
SCOEN R/W 0
SCOUT output control 0: I/O port 1: SCOUT output
ALEEN
0/1 (Note 2) ALE pin output control 0: HZ port 1: ALE output
CLKEN
0/1 (Note 2) CLK pin output control 0: HZ port 1: CLK output
Note 1: Note 2:
SYSCR1 are always 1. In the TMP93CS40, resetting sets the and bits to 0. In the TMP93CS41, resetting sets the and bits to 1 (Output ALE and CLK). The CLK pin is internally pulled up during reset, regardless of the product types. Writing 0 to SYSCR1 enables the high-frequency oscillator regardless of the value of SYSCR0. Additionally, writing 1 to SYSCR1 enables the low-frequency oscillator regardless of the value of SYSCR0.
Note 3:
Figure 3.3.3 I/O Register about Dual Clock, Standby
93CS40-17
2004-02-10
TMP93CS40/TMP93CS41 3.3.1 System Clock Controller
The system clock controller generates the system clock signal (fSYS) for the CPU core and internal I/O. It contains two oscillation circuits and a clock gear circuit for high frequency (fc). The register SYSCR1 changes the system clock to either fc or fs, SYSCR0 and SYSCR0 control enabling and disabling each oscillator, and SYSCR1 changes the high-frequency clock gear to either 1, 2, 4, 8, or 16 (fc, fc/2, fc/4, fc/8, or fc/16). These functions can reduce the power consumption of the equipment in which the device is installed. The system clock (fSYS) is set to fc/32 (fc/16 x 1/2) by the setting of = 1, = 0, = 0, and = 100 upon resetting. For example, fSYS is set to 0.625 MHz by resetting in the case where the 20 MHz oscillator is connected to the X1 and X2 pins. The high frequency (fc) and low frequency (fs) clock signals can be easily obtained by connecting a resonator to the X1 and X2, XT1 and XT2 pins, respectively. Clock input from an external oscillator is also possible. The XT1 and XT2 pins can also function as ports 96 and 97. Therefore in the case of single clock mode, the XT1 and XT2 pins can be used as I/O port pins.
High-frequency clock X1 X2 X1 X2 XT1 Low-frequency clock XT2 XT1 XT2 (Open) 74HCU04 * See application circuit in chapter 5. (a) Crystal/ceramic resonator (b) External oscillator (c) Crystal resonator (b) External oscillator
Figure 3.3.4 Examples of Resonator Connection Note 1: Note on using the low-frequency oscillation circuit. In connecting the low-frequency resonator to ports 96 and 97, it is necessary to make the following settings to reduce the power consumption. (Connecting with resonators) P9CR = 11, P9 = 00 (Connecting with oscillators) P9CR = 11, P9 = 10 Note 2: Accurate adjustment of the oscillation frequency The CLK pin output at 1/2 the system clock frequency (fSYS/2) is used to monitor the oscillation clock. With a system requiring adjustment of the oscillation frequency, an adjusting program must be written.
93CS40-18
2004-02-10
TMP93CS40/TMP93CS41
(1) Switching from NORMAL to SLOW mode When the resonator is connected to the X1 and X2, or to the XT1 and XT2 pins, the warm-up timer is used to change the operation frequency after stable oscillation is attained. The warm-up time can be selected by WDMOD. This starting and stopping of the warm-up timer are performed by programming as in the following examples 1 and 2. Note 1: The warm-up timer is also used as a watchdog timer. So when it is to be used as a warm-up timer, the watchdog timer function must be disabled. Note 2: In the case of using an oscillator (not resonator) with stable oscillation, a warm-up timer is not needed. Note 3: The warm-up timer is operated by an oscillation clock. Therefore there is an error in, warm-up time. Table 3.3.2 Warm-up Time Warm-up time WDMOD
0 (214/frequency) 1 (216/frequency)
Change to NORMAL (fc)
0.8192 ms 3.2768 ms
Change to SLOW (fs)
500 ms 2000 ms at fc = 20 MHz, fs = 32.768 kHz
93CS40-19
2004-02-10
TMP93CS40/TMP93CS41
Clock setting example 1: Changing from high frequency (fc) to low frequency (fs).
SYSCR0 SYSCR1 WDCR WDMOD EQU EQU EQU EQU RES LD SET SET SET WUP: BIT JR SET RES SET 006EH 006FH 005DH 005CH 7, (WDMOD) (WDCR), B1H 4, (WDMOD) 6, (SYSCR0) 2, (SYSCR0) 2, (SYSCR0) NZ, WUP 3, (SYSCR1) 7, (SYSCR0) 7, (WDMOD) ; ; Disables watchdog timer.
; Sets warm-up time to 216/fs. ; Enables low-frequency oscillation. ; Clears and starts warm-up timer. ; ; Detects stopping of the warm-up timer.
; Changes fSYS from fc to fs. ; Disables high-frequency oscillation. ; Enables watchdog timer.
X1 and X2 pins XT1 and XT2 pins Warm-up timer Stopping of warm-up timer System clock fSYS fc fs Counts up by fSYS Counts up by fs
Enables low frequency
Clears and starts warm-up timer
Changes fSYS Disables high frequency from fc to fs Stopping of warm-up timer
93CS40-20
2004-02-10
TMP93CS40/TMP93CS41
Clock setting example 2: Changing from low frequency (fs) to high frequency (fc).
SYSCR0 SYSCR1 WDCR WDMOD EQU EQU EQU EQU RES LD RES SET SET WUP: BIT JR RES RES SET 006EH 006FH 005DH 005CH 7, (WDMOD) (WDCR), B1H 4, (WDMOD) 7, (SYSCR0) 2, (SYSCR0) 2, (SYSCR0) NZ, WUP 3, (SYSCR1) 6, (SYSCR0) 7, (WDMOD) ; ; Disables watchdog timer.
; Sets warm-up time to 214/fc. ; Enables high-frequency oscillation (fc). ; Clears and starts warm-up timer. ; ; Detects stopping of the warm-up timer.
; Changes fSYS from fs to fc. ; Disables low-frequency oscillation. ; Enables watchdog timer.
X1 and X2 pins XT1 and XT2 pins Warm-up timer Stopping of warm-up timer System clock fSYS Changes fSYS from fs to fc Stopping of warm-up timer Disables low frequency fs fc Counts up by fSYS Counts up by fc
Enables high frequency
Clears and starts warm-up timer
93CS40-21
2004-02-10
TMP93CS40/TMP93CS41
(2) Clock gear controller When the high-frequency clock fc is selected at SYSCR1 = "0", the clock gear select register SYSCR1 sets fFPH to either fc, fc/2, fc/4, fc/8, or fc/16. Switching fFPH with the clock gear reduces the power consumption. Clock setting example 3: Changing gear value of the high-frequency clock
SYSCR1 EQU 006FH ; Changes fSYS to fc/2. LD (SYSCR1), XXXX0000B X: Don't care
(High-frequency clock gear changing) To change the frequency of the clock gear, write the value to the SYSCR1 register. It is necessary to continue the warm-up time until changing fFPH after writing the register value. There is a possibility that the instruction immediately following the clock-gear-changing instruction will be executed by the clock gear before executing its gear change. To ensure that the instruction immediately following the clock-gear-changing instruction will only be executed by the clock gear after changing its gear ratio, input a dummy instruction (An instruction to execute a write cycle) as follows. Example: Instruction to be executed by the clock gear after changing its gear ratio.
SYSCR1 EQU 006FH LD (SYSCR1), XXXX0001B LD (DUMMY), 00H ; Changes fSYS to fc/4. ; Dummy instruction.
Instruction to be executed by the clock gear after changing.
93CS40-22
2004-02-10
TMP93CS40/TMP93CS41 3.3.2 Prescaler Clock Controller
The 9-bit prescaler provides a clock signal to the 8-bit timer 0 and timer 1, 16-bit timer 4 and timer 5, and serial interface 0 and serial interface 1. The 5-bit prescaler provides a clock signal to the 8-bit PWM timer 0 and 1. The clock input to the 5-bit prescaler is a clock signal which is selected as either fFPH, fc/16, or fs according to the value in the SYSCR0 register, and divided by 2. The clock input to the 9-bit prescaler is a clock signal which is selected as either fFPH, fc/16, or fs according to the value in the SYSCR0 register, and divided by 4. The register is initialized to 00 by resetting. When the IDLE1 mode (Operating only the oscillator) is being used, set TRUN to 0 to reduce the power consumption before a HALT instruction is executed.
3.3.3
Internal Clock Pin Output Function
(1) PA7/SCOUT pin The PA7/SCOUT pin outputs the internal clock signals fFPH or fSYS. One bit in the port A control register PACR, and two bits in the clock output control register CKOCR specify the clock and the pins. The PA7/SCOUT pin is assigned as the input port in resetting. Table 3.3.3 shows states of the SCOUT pin in the alternative operation modes which it can assume on condition that the PA7/SCOUT pin is specified as SCOUT output. Table 3.3.3 SCOUT Pin States in Alternative Operation Modes Operation Mode Output Clock
fFPH fSYS
NORMAL, SLOW
Outputs fFPH clock. Outputs fSYS clock.
HALT Mode RUN, IDLE2, IDLE1 STOP
Fixed to 0 or 1.
93CS40-23
2004-02-10
TMP93CS40/TMP93CS41
(2) CLK pin The CLK pin outputs the internal clock signal fSYS divided by 2. The type of output is determined by one bit in the clock output control register, CKOCR. Writing 1 sets the clock output, and writing "0" sets the CLK pin to high impedance. CKOCR is set to "0" upon resetting. During resetting, the CLK pin is internally pulled up regardless of the value of the register. Table 3.3.4 States of the Register, and CLK Pin Operation after Reset Type No.
TMP93CS40 TMP93CS41
CKOCR
0 1
CLK Pin Operation
High impedance fSYS/2 clock output
Note:
To set CKOCR = "0" and set the CLK pin to high impedance, an external pull-up resistor is needed to prevent current from flowing to the input buffer of the CLK pin.
93CS40-24
2004-02-10
TMP93CS40/TMP93CS41 3.3.4 Standby Controller
(1) HALT mode When the HALT instruction is executed, the operating mode changes to RUN, IDLE2, IDLE1 or STOP mode depending on the contents of the HALT mode setting register WDMOD. Figure 3.3.5 shows the alternative states of the watchdog timer mode registers. Watchdog Timer Mode Register 7
WDMOD Bit symbol (005CH) Read/Write After reset Function WDTE 1
Watchdog timer control 0: Disable 1: Enable
6
WDTP1 0
5
WDTP0 0
4
WARM 0
Warm-up timer 0: 214/clock frequency selection 1: 216/clock frequency selection
3
HALTM1 R/W 0
2
HALTM0 0
1
RESCR 0
0
DRVE 0
Watchdog timer detect time selection 00: 215/fSYS 01: 217/fSYS 10: 219/fSYS 11: 2 /fSYS
21
HALT mode selection 00: RUN mode 01: STOP mode 10: IDLE1 mode 11: IDLE2 mode
Runaway STOP mode detection pin control internal 1: Drive pins reset control in STOP 1: Executes mode internal reset by runaway detection
Pin state control in STOP mode 0 1 I/O off Retains the state before HALT
HALT mode setting 00 RUN mode (only CPU stops) 01 STOP mode (all circuits stop) 10 IDLE1 mode (only oscillator operating) 11 IDLE2 mode (partial I/O operation) Warm-up time selection at returning from the STOP mode (see table 3.3.7) 0 1 214/select clock frequency 216/select clock frequency
Figure 3.3.5 Watchdog Timer Mode Register The features of the RUN, IDLE2, IDLE1, and STOP modes are as follows. 1. RUN: Only the CPU HALTs. 2. IDLE2: The built-in oscillator and the specified I/O operates. 3. IDLE1: Only the built-in oscillator operates, while all other built-in circuits stop. 4. STOP: All internal circuits including the built-in oscillator stop. This greatly reduces power consumption. The operations in the halt state are described in Table 3.3.5.
93CS40-25
2004-02-10
TMP93CS40/TMP93CS41
Table 3.3.5 I/O Operation during HALT Mode HALT mode
WDMOD CPU I/O port 8-bit timer 8-bit PWM timer Block 16-bit timer Pattern generator Serial interface AD converter Watchdog timer Interrupt controller Operate STOP
RUN
00
IDLE2
11 HALT
IDLE1
10
STOP
01
Maintain the state when the HALT instruction was executed.
See Table 3.3.8
(2) How to release the HALT mode These halt states can be released by resetting or by requesting an interrupt. The halt release sources are determined by the combinations between the states of the interrupt mask register and the HALT modes. The details for releasing the halt status are shown in Table 3.3.6. * Release by requesting an interrupt This method of releasing operation from the HALT mode depends on the interrupt-enabled status being in force. When the interrupt request level set before executing the HALT instruction exceeds the value of the interrupt mask register, the interrupt due to that source is processed after releasing the HALT mode, and then the CPU starts executing the next instruction that follows the HALT instruction. When the interrupt request level set before executing the HALT instruction is less than the value of the interrupt mask register, release of the HALT mode is not executed. (In non-maskable interrupts, interrupt processing is preformed after releasing the HALT mode regardless of the value of the mask register.) INT0 interrupts are a special case in which release of the HALT mode is executed even if the interrupt request level set before executing the HALT instruction is less than the value of the interrupt mask register. In this case interrupt processing is not performed, and the CPU starts executing the next instruction that follows the HALT instruction, but the interrupt request flag is held at 1. Note: Usually, interrupts can release all halts status. However, the interrupts = ( NMI , INT0) which can release the HALT mode may not be able to do so if they are input during the period CPU is shifting to the HALT mode (for about 3 clocks of fFPH) with IDLE1 or STOP mode (IDLE2 and RUN are not applicable to this case). (In this case, an interrupt request is kept on hold internally.) If another interrupt is generated after it has shifted to HALT mode completely, halt status can be released without difficultly. The priority of this interrupt is compare with that of the interrupt kept on hold internally, and the interrupt with higher priority is handled first followed by the other interrupt. Release by resetting Resetting releases all halt status settings. It is necessary to allow enough resetting time (3 ms or more) for the operation of the oscillator to stabilize.
*
93CS40-26
2004-02-10
TMP93CS40/TMP93CS41
When releasing the HALT mode by resetting, the internal RAM data keeps the state before the "HALT" instruction is executed. However the other setting contents are initialized (Releasing due to interrupts keep the state before the "HALT" instruction is executed.) When the HALT mode is released by resetting, the internal RAM data maintains the state it was in before the HALT instruction was executed. However the other setting contents are initialized. (Release of the HALT mode due to interrupts maintains all setting contents in their states before the HALT instruction was executed.) Table 3.3.6 Halt Release Sources and Halt Release Operations Interrupt Receiving Status HALT Mode
Halt release source Interrupt NMI INTWDT INT0 INT4 to INT7 INTT0 to INTT3 INTTR4 to INTTR7 INTRX0, TX0 INTRX1, TX1 INTAD RESET
Interrupt Enabled
(Interrupt level) (Interrupt mask)
Interrupt Disabled
(Interrupt level) < (Interrupt mask)
RUN

IDLE2 IDLE1 STOP
x x x x x x x x x x x x x x x x
*1 *1
RUN
- -
IDLE2 IDLE1 STOP
- - - - - -
x x x x x x
x x x x x x
x x x x x x
*1
x x x x x x
: After release of the HALT mode, the CPU starts interrupt processing. (RESET initializes LSI.)
: After release of the HALT mode, the CPU starts executing the next instruction that follows the HALT instruction.
x: Cannot be used to release the HALT mode. -: This combination type does not exist because the priority level (Interrupt request level) of non-maskable interrupts is fixed to the highest priority level 7. *1: Release the HALT mode is executed after the warm-up cycle is completed. Note: When release of the HALT mode is executed by an INT0 interrupt of the level mode in the interrupt enabled status, maintain level H until the start of interrupt processing. If level L is set before the start of interrupt processing, interrupt processing is correctly started.
Example of releasing the RUN mode: An INT0 interrupt releases the halt state when the RUN mode is on.
Address 8203H 8206H 8209H 820BH 820EH INT0
LD LD EI LD HALT
(IIMC), 00H (INTE0AD), 06H 5 (WDMOD), 00H
; Select interrupt rising edge. ; Sets interrupt level to 6 for INT0. ; Sets interrupt level to 5 for CPU. ; Sets HALT mode to run. ; Halts CPU. INT0 interrupt routine
820FH
LD
XX, XX
RETI
93CS40-27
2004-02-10
TMP93CS40/TMP93CS41
(3) Operation 1. RUN mode In the RUN mode, the system clock in the MCU continues to operate even after a HALT instruction is executed. Only the CPU stops executing further instructions. In the halt state, an interrupt request is accepted on the falling edge of the CLK signal. Release of the RUN mode is executed by the external or internal interrupts. (See Table 3.3.6 "Halt Release Sources and Halt Release Operations".) Figure 3.3.6 shows the timing for releasing the halt state by interrupts in the RUN or IDLE2 modes.
X1 CLK A0 to A23 ALE AD0 to AD15
RD WR NMI
Address
Address + 2
Address
Data
Address
Address
Data
INT0
(Level)
INT4 to INT7 (Rising edge) INT4, INT6 (Falling edge) Internal INT
RUN or IDLE2 modes
Figure 3.3.6 Timing Chart for Releasing the Halt State by Interrupt in RUN/IDLE2 Modes 2. IDLE2 mode In the IDLE2 mode, the system clock signal is supplied only to specific internal I/O devices, and the CPU stops executing the current instruction. In the IDLE2 mode, the halt state is released by an interrupt with the same timing as in the RUN mode. The IDLE2 mode is released by external or internal interrupts, except for INTWDT and INTAD interrupts. (See Table 3.3.6 "Halt Release Sources and Halt Release Operations".) In the IDLE2 mode, the watchdog timer should be disabled before entering the halt status, to prevent the watchdog timer interrupt from occurring just after release of the HALT mode.
93CS40-28
2004-02-10
TMP93CS40/TMP93CS41
3. IDLE1 mode In the IDLE1 mode, only the internal oscillator operates. The system clock in the MCU stops, and the CLK pin is fixed at the level H in the output enabled state. (CKOCR = 1) In the halt state, an interrupt request is sampled unsyncronously with the system clock, however the halt release (Restart of operation) is performed synchronously with it. IDLE1 mode is released by external interrupts (NMI, INT0). (See Table 3.3.6 "Halt Release Sources and Halt Release Operations".) When the IDLE mode is used, set (TRUN to 0) to stop the 9 bit and 5 bit prescaler before a HALT instruction is executed, to reduce the power consumption. Figure 3.3.7 illustrates the timing for releasing the halt state by interrupts in the IDLE1 mode
X1 CLK A0 to A23 ALE AD0 to AD15
RD WR NMI
Address
Address + 2
Address
Data
Address
Data
INT0 (Level) INT0 (Rising edge) IDLE1 mode
Figure 3.3.7 Timing Chart of Halt State Release by Interrupts in IDLE1 Mode
93CS40-29
2004-02-10
TMP93CS40/TMP93CS41
4. STOP mode The STOP mode is selected to stop all internal circuits including the internal oscillator. The pin status in the STOP mode depends on the setting of a bit in the watchdog timer mode register WDMOD. (See Table 3.3.8 for setting of WDMOD.) Table 3.3.8 summarizes the state of these pins in the STOP mode. The STOP mode is released by external interrupts (NMI, INT0). When the STOP mode is released, the system clock output starts after the warm-up time required to attain stable oscillation. The warm-up time can be set using WDMOD. See the example of warm-up time setting (Table 3.3.7). In a system which supplies a stable clock signal generated by an external oscillator, the warm-up time can be reduced by using the setting of T45CR. Figure 3.3.8 illustrates the timing for releasing the halt state by interrupts during the STOP mode.
Warm-up time X1 CLK A0 to A23 ALE AD0 to AD15
RD WR NMI
Address
Address + 2
Address
Data
Address
Data
INT0 (Level) INT0 (Rising edge) STOP mode
Figure 3.3.8 Timing Chart of Halt State Release by Interrupts in STOP Mode Table 3.3.7 Example of Warm-up Time after Releasing the STOP Mode Clock Operation Frequency after the STOP Mode is Released
fc fc/2 fc/4 fc/8 fc/16 fs
Warm-up Time [ms] WDMOD = 0 WDMOD = 1
0.8192 1.6384 3.2768 6.5536 13.1072 500 3.2768 6.5536 13.1072 26.2144 52.4288 2000
Clock Frequency
fc = 20 MHz
fs = 32.768 kHz
93CS40-30
2004-02-10
TMP93CS40/TMP93CS41
How to calculate the warm-up time WDMOD = 0: Clock operation frequency after the 214/STOP mode WDMOD = 1: Clock operation frequency after the 216/STOP mode The selection of NORMAL versus SLOW modes is possible after the STOP mode is released. This selection is mode according to the contents of the SYSCR0 register. Therefore, setting , , and is necessary before the HALT instruction is executed. Setting example: In this illustrative case, the STOP mode is entered while the clock is operating at low frequency (fs). After the STOP mode is released by a NMI interrupt, the clock resumes operation at high frequency.
Address SYSCR0 SYSCR1 WDMOD 8FFDH 9000H 9002H 9005H
NMI
EQU EQU EQU LD RES LD HALT
006EH 006FH 005CH (SYSCR1), 08H 4,(WDMOD) (SYSCR0), -11000 - - B
; fSYS = fs/2. ; Sets warm-up time to 214/fc. ; Operates at high frequency after STOP mode is released. Clears and starts warm-up timer (High frequency) End
NMI interrupt routine
9006H
LD -: No change
XX, XX
RETI
Note: When different operation modes are used before and after the STOP mode, and halt release interrupt request is accepted during execution of the HALT instruction (8 states), it is possible to release the HALT mode without changing the operation mode. In a system which accepts interrupts during execution of the HALT instruction, set the same operation mode before and after the STOP mode.
93CS40-31
2004-02-10
TMP93CS40/TMP93CS41
Table 3.3.8 Pin States in STOP Mode Pin name
P00 to P07 Input mode Output mode AD8 to AD15 Input mode Output mode AD0 to AD7 Input mode Output mode, A0 to A7/A16 to A23 Output Input mode Output mode Input mode Output mode Input mode Output mode Input mode Input mode Output mode Input mode Output mode Input mode Output mode Input mode Output mode Input mode (INT0) Input mode Output mode Input mode Output mode Input mode Output mode, SCOUT Input Output Output ( = 1) Output ( = 1) Input Input Input Input Output Input mode Output mode XT1 Input mode Output mode XT2
I/O
TMP93CS40
= 0
- - - - - PU* PU* PU* PU* PD* PD* PU* PU* PU* PU* PU* PU* PU PU Input PU* PU* - - - - Input Output "L" - Input Input Input - "H" - - - - - -
TMP93CS41
= 0 x x
-
= 1
Output - Output - Output Output Input Output Input Output Input Output Input Output Input Output Input Output Input Output Input Input Output Input Output Input Output Input Output "L" "H" Input Input Input - "H" Input Output* - Input Output* -
= 1 x x
-
P10 to P17
x x
- -
x x
- Output "H"
P20 to P27 P30 ( RD ), P31 ( WR ) P32 to P37 P40, P41 P42 (CS2/CAS2) P5 P6 P7 P80 to P86 P87 (INT0)
P90 to P95 PA0 to PA6 PA7
NMI
The same as for TMP93CS40
WDOUT ALE CLK
RESET EA
AM8/ AM16 X1 X2 P96
P97
(Align) -: Input: Output: Output*: PU: PU*: PD*: :
x:
Input is not accepted; output is at high impedance. Input gate in operation. Fix input voltage to "L" or "H" so that the input state pin stays constant. Output state. Open-drain output state. Input gate in operation. Set output to "L" or attach pull up on pin so that the input gate stays constant. Programmable pull-up pin. When a pull-up resistor is not set, fix the pin to avoid through current because the input gate always operates. Programmable pull-up pin in input gate disable state. No through current flows even if the pin is set to high impedance. Programmable pull-down pin in input gate disable state. No through current flows even if the pin is set to high impedance. When a HALT instruction is executed and CPU stops at the address of the port register, an input gate operates. Fix the pin to avoid through current, and change the program. In all other cases, input is not accepted; output is at high impedance. Cannot be set.
93CS40-32
2004-02-10
TMP93CS40/TMP93CS41
Note: Port registers are used for controlling programmable pull up/pull down. If a pin can be used for an output function (e.g., P71/TO1) and the output function is specified, whether pull up or pull down is selected depends on the output function data. If a pin can be used for an input function, whether pull up or pull down is selected depends on the port register setting value only.
93CS40-33
2004-02-10
TMP93CS40/TMP93CS41
3.4
Interrupts
Interrupts are controlled by the CPU interrupt mask register SR and the built-in interrupt controller. Altogether the TMP93CS40 and TMP93CS41 have the following 29 interrupt sources: * * * Interrupts from the CPU, 9 sources (Software interrupts, and illegal (Undefined) instruction execution) Interrupts from external pins ( NMI , INT0, and INT4 to INT7), 6 sources Interrupts from built-in I/Os, 14 sources
A fixed individual interrupt vector number is assigned to each interrupt source; any one of six levels of priority can also be assigned to each maskable interrupt. Non-maskable interrupts have a fixed priority of 7. When an interrupt is generated, the interrupt controller sends the value of the priority of the interrupt source to the CPU. When more than one interrupt is generated simultaneously, the interrupt controller sends the value of the highest priority (7 for non-maskable interrupts is the highest) to the CPU. The CPU compares the value of the priority sent, with the value in the CPU interrupt mask register . If the value sent is greater than in that the CPU interrupt mask register, the interrupt is accepted. However, software interrupts and illegal instruction execution interrupts are not compared with the register. They are given top priority. The value in the CPU interrupt mask register can be changed using the EI instruction. Executing EI n changes the contents of to n. For example, programming EI 3 enables acceptance of maskable interrupts with a priority of 3 or greater, and non-maskable interrupts which are set in the interrupt controller. When EI or EI 0 is programmed, maskable interrupts with a priority of 1 or greater, and non-maskable interrupts are enabled in the interrupt instructions (In the same way as the EI 1). The DI instruction operates in the same way as the EI 7 instruction, setting = 7. Since the priority values for maskable interrupts are 0 to 6, the DI instruction is used to disable acceptance of maskable interrupts. The EI instruction becomes effective immediately after execution. (With the TLCS-90, the EI instruction becomes effective after execution of the next following instruction.) In addition to the general-purpose interrupt processing mode described above, there is also a micro DMA processing mode. Micro DMA is a mode used by the CPU to automatically transfer byte or word data. It enables the CPU to process interrupts such as data saves to built-in I/Os at high speed. Figure 3.4.1 is a flowchart showing overall interrupt processing.
93CS40-34
2004-02-10
TMP93CS40/TMP93CS41
Interrupt processing
Read interrupt vector V. Clear interrupt request flag.
Internal operation
Vector V = Micro DMA start vector? No
Yes Data transfer by micro DMA
General-purpose interrupt processing
PUSH PC PUSH SR SR Accepted interrupt level + 1 INTNEST INTNEST + 1
Count Count - 1
Micro DMA processing
(Note) Yes Count = 0?
No PC (8000H + V)
Interrupt processing program User program RETI instruction POP SR POP PC INTNEST INTNEST - 1
Note: In read-only mode, always branches to No without conditional branch.
End
Figure 3.4.1 Interrupt Processing Flowchart
93CS40-35
2004-02-10
TMP93CS40/TMP93CS41 3.4.1 General-purpose Interrupt Processing
When accepting an interrupt, the CPU operates as follows. In the cases of software interrupts or interrupts generated by the CPU because of attempts to execute illegal instructions, the following steps (1) and (3) are not executed. (1) The CPU reads the interrupt vector from the interrupt controller. When more than one interrupt with the same priority level is generated simultaneously, the interrupt controller generates interrupt vectors in accordance with the default priority, then clears the interrupt request. The default priority is fixed as follows: The smaller the vector value, the higher the priority. (2) The CPU pushes the program counter and the status register to the system stack area (Area indicated by the system mode stack pointer (XSP)). (3) The CPU sets a value in the CPU interrupt mask register that is higher by 1 than the priority level value of the accepted interrupt. However, if the accepted interrupt's priority value is 7, 7 is set without an increment. (4) The CPU increments the interrupt nesting counter (INTNEST). (5) The CPU jumps to an address stored in the 8000H + interrupt vector, then starts the interrupt processing routine. The following table shows the number of processing states corresponding to steps 1 to 5 above. Bus Width of Stack Area
8 bits 16 bits
Bus Width of Interrupt Vector Area
8 bits 16 bits 8 bits 16 bits
Number of Interrupt Processing States Max Mode
35 31 29 25
Min Mode
31 27 27 23
The RETI instruction is usually used to complete the interrupt processing. Executing this instruction restores the contents of the program counter and the status registers, and decrements the interrupt nesting counter (INTNEST). Though acceptance of non-maskable interrupts cannot be disabled by programming, acceptance of maskable interrupts can. A priority can be set for each source of maskable interrupts. The CPU accepts any interrupt request with a priority higher than the current value in the CPU mask register . The CPU mask register is then set to a value higher by 1 than the priority of the accepted interrupt. Thus, if another interrupt is generated with a priority level higher than the interrupt currently being processed, the CPU accepts the interrupt with the higher level, causing interrupt processing to nest. If an interrupt request with a priority higher than the currently-processed interrupt is generated during the time that CPU is processing the above steps (1) to (5), and is accepted before the first instruction in the interrupt processing routine is executed, this will cause interrupt processing to nest. (The nesting process is the same as in the case of overlapping each non-maskable interrupt (Level 7).) The CPU does not accept an interrupt request of the same priority level as that of the interrupt currently being processed. Resetting initializes the CPU mask registers to the value 7; therefore, acceptance of all maskable interrupts is disabled.
93CS40-36
2004-02-10
TMP93CS40/TMP93CS41
(1) Maskable interrupt (main) EI 1 [1] INTT0 (Level 1) [5] [4] IFF1 RETI IFF2 [2] (INTT0 interrupt routine)
(2) Non-maskable interrupt (main) (NMI routine)
DI [1]
NMI
IFF7 [2]
[3]
(Level 7) [5] [4] IFF7
[3]
RETI
During execution of the main program, the CPU accepts an interrupt request. The CPU then increments IFF so that no new interrupts of priority level 1 will be accepted during processing of the interrupt routine.
The DI instruction is executed in the main program, so that only interrupts of priority level 7 are accepted. In this state the CPU does not increment the IFF even if the CPU accepts an interrupt request of level 7.
(3) Interrupt nesting (main) EI 3 [1] INTT0 (Level 3) [9] [8] IFF3 RETI IFF4 [2] [3] INTT1 (Level 4) [7] [6] IFF4 RETI IFF5 [4] (INTT0 interrupt routine)
(4) Software interrupt (INTT1 interrupt routine) (main) DI [1] [2] (SWI3 routine)
[5]
SWI 3 [5] [4]
[3]
RETI
During processing an interrupt of priority level 3, the IFF is set to 4. When an interrupt with a level higher than 4 is generated, the CPU accepts the interrupt with the higher priority level, causing interrupt processing to nest.
The CPU accepts a software interrupt request during DI status (IFF = 7) because the request has a priority of level 7. The IFF is not changed by the software interrupt.
(5) Timing of interrupt acceptance (main) EI 3 [1] INTT0 (Level 3) [8] [7] [6] RETI RETI INTT1 (Level 4) [2] (INTT0 interrupt routine) (INTT1 interrupt routine) [3]
XXX
[5]
[4] (underline): Instruction [1], [2], ...: Execution flow
If an interrupt with a priority level higher than the interrupt currently being processed is generated, the CPU accepts the interrupt with the higher level. The program counter which returns at [5] is the state address of the INTT0 interrupt routine.
93CS40-37
2004-02-10
TMP93CS40/TMP93CS41
The addresses 008000H to 0080FFH (256 bytes) of the TMP93CS40 and TMP93CS41 are assigned as interrupt vector areas. Table 3.4.1 TMP93CS40/TMP93CS41 Interrupt Table Default Priority
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - 16 17 18 19 20 21 22 23 24 25 26 27 28 - -
Type
Interrupt Source
Reset, or SWI0 instruction SWI 1 instruction Illegal instruction, or SWI2 SWI 3 instruction SWI 4 instruction SWI 5 instruction SWI 6 instruction SWI 7 instruction NMI: NMI pin input INTWD: Watchdog timer INT0: INT0 pin input INT4: INT4 pin input INT5: INT5 pin input INT6: INT6 pin input INT7: INT7 pin input (Reserved) INTT0: 8-bit timer 0 INTT1: 8-bit timer 1 INTT2: 8-bit timer 2/PWM 0 INTT3: 8-bit timer 3/PWM 1 INTTR4: 16-bit timer 4 (TREG4) INTTR5: 16-bit timer 4 (TREG5) INTTR6: 16-bit timer 5 (TREG6) INTTR7: 16-bit timer 5 (TREG7) INTRX0: Serial receive (Channel 0) INTTX0: Serial send (Channel 0) INTRX1: Serial receive (Channel 1) INTTX1: Serial send (Channel 1) INTAD: AD conversion completion (Reserved) (Reserved)
Vector Value "v"
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 to F 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 C H H H H H H H H H H H H H H H H H H H H H H H H H H H H H H H
Address Referring to Vector
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 to F 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 8 C 0 4 C H H H H H H H H H H H H H H H H H H H H H H H H H H H H H H H
Micro DMA Start Vector
- - - - - - - - 08H 09H 0AH 0BH 0CH 0DH 0EH - 10H 11H 12H 13H 14H 15H 16H 17H 18H 19H 1AH 1BH 1CH - to -
Nonmaskable
Maskable
93CS40-38
2004-02-10
TMP93CS40/TMP93CS41
Setting to reset and interrupt vectors 1. Reset vector 8000H 8001H 8002H 8003H PC<7:0> PC<15:8> PC<23:16> XX
The vector base addresses are dependent on the products. Type No. Vector Base Address PC Setting Sequence after Reset Notes
P27 to P20 and A23 to A16 pins are defined as input ports and are pulled down in resetting. The logic data item is 00H. When port 2 is used for the A23 to A16 pins to access the program ROM, set PC (23 to 16) to 00H and set the reset vector to lie within the area 0000H to FFFFH. (This is applicable mainly to products without ROM.)
TMP93CS40/CS41 TMP93CM40 TMP93PS40 TMP93CW40/CW41 TMP93PW40
008000H
PC (7:0) Data in location 8000H PC (15:8) Data in location 8001H PC (23:16) Data in location 8002H
2.
Interrupt vector (except reset vector) +0 +1 +2 +3 PC<7:0> PC<15:8> PC<23:16> XX
Address refers to vector
XX: Don't care
93CS40-39
2004-02-10
TMP93CS40/TMP93CS41
Setting example: Set the reset vector to 8100H, NMI vector to 9ABCH and INTAD vector to 123456H. ORG DL ORG DL ORG DL ORG LD ORG LD ORG LD 8000H 008100H 8020H 009ABCH 8070H 123456H 8100H A, B 9ABCH B, C 123456H C, A
; Reset = 8100H ; NMI = 9ABCH ; INTAD = 123456H
Note: ORG and DL are assembler directives. ORG: Control location counter DL: Defines long word (32-bit) data
93CS40-40
2004-02-10
TMP93CS40/TMP93CS41 3.4.2 Micro DMA
In addition to the conventional interrupt processing, the TMP93CS40 and TMP93CS41 also have a micro DMA function. When an interrupt is accepted, in addition to an interrupt vector, the CPU receives data indicating whether it is to be processed in micro DMA mode or in general-purpose interrupt mode. The CPU performs micro DMA processing only if that mode is requested. The micro DMA of the TMP93CS40 and TMP93CS41 can process at very high speed compared with the TLCS-90 micro DMA because it has transfer parameters in dedicated registers in the CPU. Since those dedicated registers are assigned as CPU control registers, they can only be accessed by the LDC instruction. (1) Micro DMA operation Micro DMA operation starts when the accepted interrupt vector value matches the micro DMA start vector value set in the interrupt controller. The micro DMA has four channels, so that it can be set for up to four types of interrupt sources at the same time. When a micro DMA interrupt is accepted, data are automatically transferred from the transfer source address to the transfer destination address set in the control register, and the transfer counter is decremented. If the value in the counter after decrementing is other than "0", micro DMA processing is completed; if the value in the counter after decrementing is "0", general-purpose interrupt processing is performed. In read-only mode, which provides for DRAM refresh, the value in the counter is ignored and a dummy read operation is repeated. 32-bit control registers are used for setting transfer source and destination addresses. However, the TMP93CS40 and TMP93CS41 have only 24 address pins for output. A 16-Mbyte space is available for the micro DMA. There are two data transfer modes: One-byte mode and one-word mode. Incrementing, decrementing, and fixing the transfer source and destination addresses after transfer can be done in both modes. Therefore data can easily be transferred between I/O and memory and between different I/Os. For details of transfer modes, see the description of transfer mode registers. The transfer counter has 16 bits, so up to 65536 transfers (The maximum when the initial value of the transfer counter is 0000H) can be performed for one interrupt source by micro DMA processing. When the transfer counter is decremented to "0" after data are transferred by micro DMA, general-purpose interrupt processing is performed. After processing general-purpose interrupt, restarting the interrupts of the same channel restarts transfer counter from 65536. It is necessary to reset the transfer counter in general-purpose interrupt processing routine. the the the the
Interrupt sources handled by micro DMA processing are 20 in total, and the micro DMA start vectors are listed in Table 3.4.1. The following timing chart is a micro DMA cycle of the transfer address increment (INC) mode (The other modes are the same as this except for the read-only mode). (Conditions: MAX mode, 16-bit bus width for 16 Mbytes, 0 waits.)
93CS40-41
2004-02-10
1 state DM2 DM5 DM6 DM11 DM12 DM3 DM4 DM7 DM8 DM9 DM10
(Note 1)
(Note 2)
(Note 3)
(Note 3) DM13 DM14
(Note 3) DM15 DM16
DM1
X1
ALE
A0 to A15
D0 to D15 A0 to A15
AD0 to AD15
D0 to D15
A0 to A15
D0 to D15
A0 to A15
D0 to D15
A0 to A15
D0 to D15
A16 to A23 Dummy Source address Destination address Dummy
Dummy
Address
Address + 2
Address + 4
Figure 3.4.2 Micro DMA Cycle (Count 0)
93CS40-42
RD
WR, HWR
Note 1: These 2 states are added in the case that the bus width of the source address area is 8 bits. Note 2: These 2 states are added in the case that the bus width of the destination address area is 8 bits. Note 3: This may be a dummy cycle with an instruction queue buffer.
TMP93CS40/TMP93CS41
2004-02-10
(Note 1) DM2 DM5 DM6 DM11 DM12 DM3 DM4 DM7 DM8 DM9 DM10 DM13 DM14 DM15
(Note 2)
(Note 3)
(Note 3) DM16
DM1
X1
ALE
A0 to A15 D0 to D15 A0 to A15
AD0 to AD15 D0 to D15
A0 to A15 D0 to D15 A0 to A15
D0 to D15
A16 to A23 Dummy Destination address Source address Dummy Address
Dummy
Address + 2
Dummy
RD
WR, HWR
(Note 4) DM18 DM19 DM20 DM21 DM22 DM23 DM25 DM26 DM24 DM27
(Note 4)
(Note 4) DM28 DM29 DM30 DM31 DM32
DM17
X1
ALE XSP - 6 XSP - 4 XSP - 2 Dummy 8000H + V 8002H + V Dummy
AD0 to AD15
Dummy
Figure 3.4.3 Micro DMA Cycle (Count = 0)
DM34 DM35 DM36 DM37 Address Address + 2
93CS40-43
RD
WR, HWR
DM33
Note 1: These 2 states are added in the case that the bus width of the source address area is 8 bits or the address starts from an odd number. Note 2: These 2 states are added in the case that the bus width of the destination address area is 8 bits or the address starts from an odd number. Note 3: This may be a dummy cycle with an instruction queue buffer. Note 4: These 2 states are added in the case that the bus width of the stack address area is 8 bits or the stack pointer starts from an odd number.
X1
ALE
AD0 to AD15
Dummy
RD
WR, HWR
TMP93CS40/TMP93CS41
2004-02-10
TMP93CS40/TMP93CS41
(2) Register configuration (CPU control registers)
Channel0 DMAS0 DMAD0 DMAC0 DMAM0 Channel1 DMAS1 DMAD1 DMAC1 DMAM1 Channel2 DMAS2 DMAD2 DMAC2 DMAM2 Channel3 DMAS3 DMAD3 DMAC3 DMAM3 8 bits 16 bits 32 bits Transfer source address register 3 Transfer destination address register 3 Transfer counter register 3 Transfer mode register 3 Transfer source address register 2 Transfer destination address register 2 Transfer counter register 2 Transfer mode register 2 Transfer source address register 1 Transfer destination address register 1 Transfer counter register 1 Transfer mode register 1 Transfer source address register 0 Transfer destination address register 0 Transfer counter register 0 Transfer mode register 0 (1 to 65536) (Use only lower 24 bits.)
These control registers can only be set with the "LDC cr, r" instruction.
Example: LD LDC LD LDC LD LDC LD LDC
XWA, 100H DMAS0, XWA XWA, 50H DMAD0, XWA WA, 40H DMAC0, WA A, 05H DMAM0, A
93CS40-44
2004-02-10
TMP93CS40/TMP93CS41
(3) Transfer mode register details
0 0 0 0 Mode Note: When setting values for this register, set the upper 4 bits to 0. Execution time Z: 0 = byte transfer, 1 = word transfer 0 0 0 Z Transfer destination address INC mode .................................... for I/O to memory (DMADn+)(DMASn) DMACnDMACn - 1 if DMACn = 0 then INT. Transfer destination address DEC mode ................................... for I/O to memory (DMADn-)(DMASn) DMACnDMACn - 1 if DMACn = 0 then INT. Transfer source address INC mode........................................... for memory to I/O (DMADn)(DMASn+) DMACnDMACn - 1 if DMACn = 0 then INT. Transfer source address DEC mode ......................................... for memory to I/O (DMADn)(DMASn-) DMACnDMACn - 1 if DMACn = 0 then INT. Fixed address mode.................................................................. I/O to I/O (DMADn)(DMASn) DMACnDMACn - 1 if DMACn = 0 then INT. Read-only mode ........................................................................ for DRAM refresh Dummy(DMASn) ; Reads 4 bytes. DMASnDMASn + 4 ; Increments lower word only. DMACnDMACn - 1 Counter mode ........................................................................... for interrupt counter DMASnDMASn + 1 DMACnDMACn - 1 if DMACn = 0 then INT. 16 states (1.6 s) 16 states (1.6 s) 16 states (1.6 s) 16 states (1.6 s) 16 states (1.6 s) 14 states (1.4 s) 11 states (1.1 s)
0
0
1
Z
0
1
0
Z
0
1
1
Z
1
0
0
Z
1
0
1
0
1
0
1
1
Note 1: n: corresponds to micro DMA channels 0 to 3. DMADn+/DMASn+: Post-increment (Increments register value after transfer.) DMADn-/DMASn-: Post-decrement (Decrements register value after transfer.) Note 2: Execution time: When setting source address/destination address area to 16-bit bus, 0 waits. Clock condition: fc = 20 MHz, clock gear: 1 (fc) Note 3: Do not use any codes for transfer mode registers other than those indicated above.
93CS40-45
2004-02-10
TMP93CS40/TMP93CS41
* Clock condition System clock: fc Clock gear: 1 (fc)
When the hardware configuration is as follows: DRAM mapping size: DRAM data bus size: = 1 Mbyte = 8 bits
DRAM mapping address range: = 100000H to 1FFFFFH Set the following registers first; refresh is performed automatically. 1. Register initial value setting LD LDC LD LDC 2. 3. XIX, 100000H DMAS0, XIX A, 00001010B ... Read only mode (for DRAM refresh) DMAM0, A ... Mapping start address
Timer setting Set the timers so that interrupts are generated at intervals of 62.5 s or less. Interrupt controller setting Set the timer interrupt mask higher than the mask for other interrupts. Write the above timer interrupt vector value into the micro DMA start vector register, DMA0V.
(Operation description) The DRAM data bus is an 8-bit bus and the micro DMA is in read-only mode (4 bytes), so refresh is performed four times per interrupt. When a 512-refresh per 8 ms DRAM is connected, DRAM refresh is performed sufficiently if the micro DMA is started every 15.625 s x 4 = 62.5 s or less, since the timing is 15.625 s per refresh. (Overhead) Each processing time for read-only mode by the micro DMA is 1.8 s (18 states) at 20 MHz with an 8-bit data bus. In the above example, the micro DMA is started every 62.5 s, and 1.8 s / 62.5 s = 0.0288; thus, the overhead factor is 2.88%. Note: When the bus which must wait to accept the interrupt is released ( BUSAK = "0"), DRAM refresh is not performed because the micro DMA is generated by an interrupt.
93CS40-46
2004-02-10
TMP93CS40/TMP93CS41 3.4.3 Interrupt Controller
Figure 3.4.4 is a block diagram of the interrupt circuits. The left half of the diagram shows the interrupt controller; the right half includes the CPU interrupt request signal circuit and the halt release signal circuit. Each interrupt channel (Total of 20 channels) in the interrupt controller has an interrupt request flag, interrupt priority setting register, and a register for storing the micro DMA start vector. The interrupt request flag is used to latch interrupt requests from peripheral devices. The flag is cleared to 0 when any of the following conditions are met. * * * Upon resetting When the CPU reads the interrupt vector after acceptance of an interrupt. When the CPU executes an instruction that clears the interrupt from that channel (Writes 0 in of the interrupt priority setting register).
For example, to clear the INT0 interrupt request, after the DI instruction set the register INTE0AD as follows. INTE0AD - - - - 0 - - - Clears the INT0 flip-flop. The status of the interrupt request flag is detected by reading the corresponding clear bit. This also allows the interrupt to be identified by the software. The interrupt priority can be set by writing the priority in the interrupt priority setting register (e.g., INTE0AD or INTE45) provided for each interrupt source. Interrupt priority levels to be set range from or 1 to 6. Except for NMIs (Non-maskable interrupts), writing 0 or 7 as the interrupt priority disables the corresponding interrupt request. The priority of non-maskable interrupt sources ( NMI pin, watchdog timer, etc.) is fixed to 7. If interrupt requests with the same interrupt level are generated simultaneously, interrupts are accepted in accordance with the default ranking of priorities. The interrupt controller selects the interrupt request with the highest priority among the simultaneous interrupts, and sends it and its vector address to the CPU. The CPU compares the priority value set in the status register, with the priority value sent by the interrupt request signal; if the latter is higher, the interrupt is accepted. Then the CPU sets in CPU SR a value equal to one plus the priority value of the interrupt request just received. Interrupt requests whose priority values equal or are higher than the value set in the register are accepted concurrently with execution of the previous interrupt routine. When interrupt processing is completed (after execution of the RETI instruction), the CPU restores to CPU SR the priority value saved in the stack before the interrupt was generated. The interrupt controller also has four registers used to store the micro DMA start vector. Unlike other micro DMA registers (DMAS, DMAD, DMAM, and DMAC), these are I/O registers. Writing the start vector of the interrupt source for micro DMA processing (See Table 3.4.1), enables the corresponding interrupt to be processed by micro DMA. Please note that appropriate values must be set in the micro DMA parameter registers (e.g., DMAS and DMAD) prior to the beginning of micro DMA processing.
93CS40-47
2004-02-10
Interrupt controller CPU 1
NMI Interrupt enable flag on CPU side RESET Interrupt request Priority encoder signal to CPU IFF2 to 0 3 3 INTRQ2 to 0 Interrupt vector read 3 1 7
Highest A priority B interrupt C level select
Interrupt request flag S Q RESET R Interrupt vector V read V = 20H V = 24H Decoder A D Q CLR B C 6 6
INTWD Priority setting register Dn Dn + 1 Dn + 2
EI 1 to 7 DI Interrupt level detect Interrupt request signal
Y1 Y2 Y3 Y4 Y5 Y6
INT0 Dn + 3 (Highest priority = 7) 20
RESET
Interrupt request flag S Q R
1 2 3 4 5 6 7
D0 D1 D7
If INTRQ2 to 0 IFF2 to 0 then 1.
Interrupt vector generation
D2 D3 D4 D5 D6
During IDLE1 During STOP
Figure 3.4.4 Block Diagram of Interrupt Controller
93CS40-48
5 4 D CLR 5 Match detect DMA0V DMA1V DMA2V DMA3V Q 5 4-input OR
D4 D3 D2 D1 D0
Halt release RESET INT0 NMI
INT4 INT5 INT6 INT7 INTT0 INTT1 INTT2 INTT3 INTTR4 INTTR5 INTTR6 INTTR7 INTRX0 INTTX0 INTRX1 INTTX1 INTAD
Interrupt request flag read Interrupt request clear Dn + 3 Interrupt request V read V = 28H V = 2CH V = 30H V = 34H V = 38H V = 40H V = 44H V = 48H V = 4CH V = 50H V = 54H V = 58H V = 5CH V = 60H V = 64H V = 68H V = 6CH V = 70H Micro DMA start vector setting register
Micro DMA request
RESET
A B Micro DMA channel priority encoder
TMP93CS40/TMP93CS41
0 1 2 3
2
2
Micro DMA channel specification
2004-02-10
TMP93CS40/TMP93CS41
(1) Interrupt priority setting register
Symbol Address 7
IADC R/W 0 I5C R/W 0 I7C R/W 0 IT1C R/W 0 IPW1C R/W 0 IT5C R/W 0 IT7C R/W 0 ITX0C R/W 0 ITX1C R/W 0 0 0 INTTX1 INTES1 0078H ITX1M2 ITX1M1 W 0 0 ITX1M0 IRX1C R/W 0 0 0 INTTX0 INTES0 0077H ITX0M2 ITX0M1 W 0 0 ITX0M0 IRX0C R/W 0 0 INTRX1 IRX1M2 IRX1M1 W 0 0 IRX1M0 0 IT7M2 0 IT5M2 0 IPW1M2 0 IT1M2 0 INT7 INTE67 0072H I7M2 I7M1 W 0 IT1M1 W 0 IPW1M1 W 0 IT5M1 W 0 IT7M1 W 0 0 0 IT7M0 INTTR7 (TREG7) INTET76 0076H IT6C R/W 0 0 INTRX0 IRX0M2 IRX0M1 W 0 0 IRX0M0 0 IT5M0 INTTR5 (TREG5) INTET54 0075H IT4C R/W 0 0 IT6M2 0 IPW1M0 INTT3 (Timer3/PWM1) INTEPW10 0074H IPW0C R/W 0 0 IT4M2 0 IT1M0 INTT1 (Timer1) INTET10 0073H IT0C R/W 0 0 IPW0M2 I7M0 I6C R/W 0 0 IT0M2 I6M2 0 INT5 INTE45 0071H I5M2 I5M1 W 0 0 I5M0 I4C R/W 0 0 INT6 I6M1 W 0 IT0M1 W 0 IPW0M1 W 0 IT4M1 W 0 IT6M1 W 0 0 0 IT6M0 INTTR6 (TREG6) 0 IT4M0 INTTR4 (TREG4) 0 IPW0M0 INTT2 (Timer2/PWM0) 0 IT0M0 INTT0 (Timer0) I6M0 I4M2
6
INTAD IADM2
5
IADM1 W 0
4
IADM0 0
3
I0C R/W 0
2
INT0 I0M2 0 INT4
1
I0M1 W 0 I4M1 W 0
0
Interrupt source
INTE0AD
0070H
I0M0 0 I4M0 0
Bit symbol Read/Write After reset
IxxM2 0 0 0 0 1 1 1 1 IxxC 0 1
IxxM1 0 0 1 1 0 0 1 1
IxxM0 0 1 0 1 0 1 0 1
Function (Write) Prohibits interrupt request. Sets interrupt request level to "1". Sets interrupt request level to "2". Sets interrupt request level to "3". Sets interrupt request level to "4". Sets interrupt request level to "5". Sets interrupt request level to "6". Prohibits interrupt request. Function (Write) Clears interrupt request flag. Don't care
Function (Read) Indicates no interrupt request. Indicates interrupt request.
Note 1: Read-modify-write is prohibited. Note 2: This note is about clearing interrupt request flags. The interrupt request flags of INTAD, INTRX0, and INTRX1 are not cleared by writing "0" to IxxC because they are level-sense interrupts.
Figure 3.4.5 Interrupt Priority Setting Register
93CS40-49
2004-02-10
TMP93CS40/TMP93CS41
(2) External interrupt control Interrupt Input Mode Control Register 7
IIMC (007BH) Bit symbol Read/Write After reset Function
6
5
4
3
2
I0IE W 0 1: INT0 input enable
1
I0LE W 0 0: INT0 edgesense mode 1: INT0 levelsense mode
0
NMIREE W 0 1: Can be accepted in NMI rising edge.
INT0 input enable (Note 1) 0 1 INT0 disable (P87 function only) Input enable
NMI rising edge enable
0 1
Interrupt request generation at falling edge Interrupt request generation at rising and falling edge
Note 1: The INT0 pin can also be used for standby release as described in section 3.3.4. Even if the pin is not used for standby release, setting this register to "0" maintains the port function during standby mode. Note 2: This is a case of changing from level-sence to edge-sence for INT0 pin mode. Execution example: LD (INTE0AD) ,xxxx0000B LD (IIMC) ,xxxxx10xB ; INT0 disable, clear the request flag. ; Change from level to edge. ; Set interrupt level "n" for INT0, clear the request flag. Note 3: Read-modify-write is prohibited. Note 4: IMC are always read as "1". Note 5: See electrical characteristics in section 4 for external interrupt input pulse.
INT0 level enable (Note 2) 0 1 Rising edge detect interrupt High level interrupt
LD (INTE0AD) ,xxxx0nnnB
Figure 3.4.6 Interrupt Input Mode Control Register Table 3.4.2 Setting of External Interrupt Pin Function Interrupt
NMI
Pin Name
-
Mode
Falling edge Falling and rising edges Rising edge
Setting Method
IIMC = 0 IIMC = 1 IIMC = 0, = 1 IIMC = 1, = 1 T4MOD = 0, 0 or 0, 1 or 1, 1 T4MOD = 1, 0
INT0
P87 High level Rising edge
INT4
P80 Falling edge
INT5
P81
Rising edge Rising edge T5MOD = 0, 0 or 0, 1 or 1, 1 T5MOD = 1, 0
INT6
P84 Falling edge
INT7
P85
Rising edge
93CS40-50
2004-02-10
TMP93CS40/TMP93CS41
(3) Micro DMA start vector When the CPU reads the interrupt vector after accepting an interrupt, it simultaneously compares the bits 2 to 6 of the interrupt vector with each channel's micro DMA start vector. When the two match, the interrupt from the channel whose value matched is processed in micro DMA mode. If the interrupt vector matches more than one channel, the channel with the lower channel number has a higher priority. Micro DMA 0 State Vector 7
DMA0V (007CH) Bit symbol Read/Write After reset Function 0 0
6
5
4
DMA0V4
3
DMA0V3
2
DMA0V2 W 0
1
DMA0V1 0
0
DMA0V0 0
Micro DMA channel 0 processed by matching bits 2 to 6 of the interrupt vector.
Micro DMA 1 State Vector 7
DMA1V (007DH) Bit symbol Read/Write After reset Function 0 0
6
5
4
DMA1V4
3
DMA1V3
2
DMA1V2 W 0
1
DMA1V1 0
0
DMA1V0 0
Micro DMA channel 1 processed by matching bits 2 to 6 of the interrupt vector.
Micro DMA 2 State Vector 7
DMA2V (007EH) Bit symbol Read/Write After reset Function 0 0
6
5
4
DMA2V4
3
DMA2V3
2
DMA2V2 W 0
1
DMA2V1 0
0
DMA2V0 0
Micro DMA channel 2 processed by matching bits 2 to 6 of the interrupt vector.
Micro DMA 3 State Vector 7
DMA3V (007FH) Bit symbol Read/Write After reset Function 0 0
6
5
4
DMA3V4
3
DMA3V3
2
DMA3V2 W 0
1
DMA3V1 0
0
DMA3V0 0
Micro DMA channel 3 processed by matching bits 2 to 6 of the interrupt vector.
Note: Read-modify-write is not possible for DMA0V to DMA3V.
Figure 3.4.7 Micro DMA State Vector Register
93CS40-51
2004-02-10
TMP93CS40/TMP93CS41
(4) Notes The instruction execution unit and the bus interface unit of this CPU operate independently of each other. Therefore, if the instruction used to clear the interrupt request flag of an interrupt is fetched before the interrupt is generated, it is possible that the CPU might accept the interrupt and execute the fetched instruction to clear the interrupt request flag while reading the interrupt vector. If so, the CPU would start the interrupt processing from the address "8028H". To avoid the above occurring, clear the interrupt request flag by entering the instruction to clear the flag after the DI instruction. In the case of setting an interrupt enable again by EI instruction after the execution of clearing instruction, execute EI instruction after clearing instruction and following more than one instruction are executed. When EI instruction is placed immediately after clearing instruction, an interrupt becomes enable before interrupt request flags are cleared. In the case of changing the value of the interrupt mask register by execution of POR SR instruction, disable an interrupt by DI instruction before execution of POP SR instruction.
93CS40-52
2004-02-10
TMP93CS40/TMP93CS41
3.5
Functions of Ports
The TMP93CS40 has 79 bits for I/O ports. The TMP93CS41 has 61 bits for I/O ports because port 0, port 1, P30, and P31 are dedicated pins for AD0 to AD7, AD8 to AD15 or A8 to A15, RD , and WR . These port pins have I/O functions for the built-in CPU and internal I/Os as well as general-purpose I/O port functions. Table 3.5.1 lists the function of each port pin. Table 3.5.2 lists I/O registers and their specifications. Table 3.5.1 Functions of Ports Port No.
Port 0 Port 1 Port 2 Port 3
Pin No.
P00 to P07 P10 to P17 P20 to P27 P30 P31 P32 P33 P34 P35 P36 P37 P40 P41 P42 P50 to P57 P60 to P67 P70 P71 P72 P73 P80 P81 P82 P83 P84 P85 P86 P87 P90 P91 P92 P93 P94 P95 P96 P97 PA0 to PA6 PA7
Number of Pins
8 8 8 1 1 1 1 1 1 1 1 1 1 1 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 1
Direction
I/O I/O I/O Output Output I/O I/O I/O I/O I/O I/O I/O I/O I/O Input I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O
R
- - - - - - - - -
Direction Setting Unit
Bit Bit Bit (Fixed) (Fixed) Bit Bit Bit Bit Bit Bit Bit Bit Bit (Fixed) Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit
Pin Name for Built-in Function
AD0 to AD7 AD8 to AD15/A8 to A15 A0 to A7/A16 to A23
RD WR HWR WAIT
BUSRQ BUSAK
R/ W
RAS CS0 / CAS0 CS1 / CAS1 CS2 / CAS2
Port 4
Port 5 Port 6 Port 7
AN0 to AN7 PG00 to PG03, PG10 to PG13 TI0 TO1 TO2 TO3 TI4/INT4 TI5/INT5 TO4 TO5 TI6/INT6 TI7/INT7 TO6 INT0 TXD0 RXD0
CTS0 /SCLK0
Port 8
Port 9
TXD1 RXD1 SCLK1 XT1 XT2 SCOUT
Port A
R:
= With programmable pull-up resistor = With programmable pull-down resistor.
93CS40-53
2004-02-10
TMP93CS40/TMP93CS41
Table 3.5.2 I/O Registers and Specifications (1/2) Port No.
Port 0
Pin No.
P00 to P07 Input port (Note 1) Output port (Note 1) AD0 to AD7 bus
Function
I/O Register Pn
x x x x x x x
1 0
PnCR
0 1
PnFC
None 0 0 1 1 0 0 0 1 1 0 1 1 0 1 0 0 0 1 None 1 1 1 1 1 0 0 0 0 0 0 1 1 1 None
x
0 1 0 1 0 0 1 0 1 None
Port 1
P10 to P17
Input port (Note 1) Output port (Note 1) AD8 to AD15 bus (Note 2) A8 to A15 output (Note 2)
Port 2
P20 to P27
Input port (without PD) Input port (with PD) Output port A0 to A7 output (Note 1) A16 to A23 output
x
1 1
Port 3
P30
Output port (Note 1) Outputs RD only when accessing external space Always outputs RD
x
1 0
P31 P32 to P37
Output port (Note 1) Outputs WR only when accessing external space Input port (without PU) Input port (with PU) Output port
x x
0 1
None 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 1
P32 P33 P34 P35 P36 P37 Port 4 P40 to P41
HWR output
WAIT input (without PU) WAIT input (with PU) BUSRQ input (without PU) BUSRQ input (with PU) BUSAK output
x x
0 1 0 1
R/ W output RAS output
Input port (without PU) Input port (with PU) Output port
x x x
0 1
x
1 0
P42
Input port (without PD) Input port (with PD) Output port CS0 output (Note 3)
CS1 output (Note 3) CS2 output (Note 3)
P40 P41 P42 Port 5 Port 6 P50 to P57 P60 to P67
Input port AN0 to AN7 input (Note 4) Input port (without PU) Input port (with PU) Output port PGn output
x x x x x x
0 1
0 0 1 1
0 0 0 1
x x
x: Don't care Note 1: In the case of the TMP93CS41F, this function is not available. Note 2: In the case of the TMP93CS41F, this function is fixed by AM8/ AM16 pin. Note 3: CS/WAIT control register BnCH selects the wave form output from P40 to P42 pins, CS0 to CS2 or CAS0 to CAS2 . Note 4: The channel for AD input is selected by ADMOD2 for P50 to P57 pins. Note 5: PU = pull-up resistor; PD = pull-down resistor.
93CS40-54
2004-02-10
TMP93CS40/TMP93CS41
Table 3.5.3 I/O Registers and Specifications (2/2) Port No.
Port 7
Pin No.
P70 to P73
Function
Input port (without PU) Input port (with PU) Output port
I/O Register Pn
0 1
PnCR
0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 1
PnFC
0 0 0 None 1 1 1 0 0 0 None None None None 1 1 1 None 0 0 0 1 1 None None 1 0 0 1 0 0 None
x
0 1
P70 P71 P72 P73 Port 8 P80 to P87
TI0 input (without PU) TI0 input (with PU) TO1 output TO2 output TO3 output Input port (without PU) Input port (with PU) Output port
x x x
0 1
x
0 1 0 1 0 1 0 1
P80 P81 P84 P85 P82 P83 P86 P87 (Note 5) Port 9 P90 to P95
TI4/INT4 input (without PU) TI4/INT4 input (with PU) TI5/INT5 input (without PU) TI5/INT5 input (with PU) TI6/INT6 input (without PU) TI6/INT6 input (with PU) TI7/INT7 input (without PU) TI7/INT7 input (with PU) TO4 output TO5 output TO6 output INT0 input (without PU) INT0 input (with PU) Input port (without PU) Input port (with PU) Output port
x x x
0 1 0 1
P90 P93 P91 P94 P92
TXD0 output TXD1 output RXD0 input (without PU) RXD0 input (with PU) RXD1 input (without PU) RXD1 input (with PU) SCLK0 output CTS0/SCLK0 input (without PU) CTS0/SCLK0 input (with PU)
x x x
0 1 0 1
x
0 1
P95
SCLK1 output SCLK1 input (without PU) SCLK1 input (with PU)
x
0 1
P96 to P97
Input port Output port (Note 6) XT1/2 (Note 7)
Port A
PA0 to PA7 PA7
Input port Output port SCOUT output (Note 8)
x x x x x x
None
x: Don't care
Note 5: When the P87 pin is used as INT0, the IIMC register has to be set to enable interrupt. Note 6: When using P96 to P97 as output ports, output goes through the open-drain buffer. Note 7: When P96 to P97 are used as XT1 to XT2, the SYSCR0 has to be set to "1". Note 8: When PA7 is used as SCOUT, the PACR and CKOCR must have the appropriate values written to them.
93CS40-55
2004-02-10
TMP93CS40/TMP93CS41
Resetting makes the port pins listed below function as general-purpose I/O ports. I/O pins programmable for input or output are then set to function as input ports, except for P96/XT1 and P97/XT2. A program is needed to set port pins for built-in functions. Because the TMP93CS41 needs external ROMs, some ports are permanently assigned for memory interfacing. * P00 to P07 AD0 to AD7 * P30 RD * P10 to P17 AD8 to AD15 (or A8 to A15) * P31 WR * Note about the bus release and programmable pull-up/pull-down I/O ports.
When the bus is released ( BUSAK = "0"), the output buffers of AD0 to AD15 and A0 to A23, as well as the control signals ( RD , WR , HWR , R / W , RAS , CS0 / CAS0 to CS2 / CAS2 ) are all set to OFF and they go into a high-impedance state. However, the states of the built-in programmable pull-up/pull-down resistors are retained when the bus is released. These programmable pull-up/pull-down resistors can be switched ON or OFF by programming when they are used as input ports. When they are used as output ports, they cannot be switched by programming. Table 3.5.4 shows the pin states when the bus is released ( BUSAK = "0") Table 3.5.4 Pin States (when the bus is released) Pin Name
P00 to P07 (AD0 to AD7) P10 to P17 (AD8 to AD15/A8 to A15) P30 ( RD ) P31 ( WR ) P32 ( HWR ) P37 ( RAS )
Pin States (when the bus is released) Used as a Port
The state is not changed. (does not go to high-impedance (High-Z).)
Used for a Function
Goes to high-impedance (High-Z).
Goes to high-impedance (High-Z). The output buffer is OFF. The programmable pull-up resistor is ON only in the case that the output latch is equal to "1".
The output buffer is OFF. The programmable pull-up resistor is ON only in the case that the output latch is equal to "1". The output buffer is OFF. The programmable pull-down resistor is ON only in the case that the output latch is equal to "0".
Goes to high-impedance (High-Z). The output buffer is OFF. The programmable pull-up resistor is ON irrespective of the output latch.
The output buffer is OFF. The state of the programmable pull-up resistor is retained when the bus is released. The output buffer is OFF. The state of the programmable pull-down resistor is retained when the bus is released. The output buffer is OFF. The programmable pull-down resistor is ON only in the case that the output latch is equal to "0".
P36 ( R/ W ) P40 ( CS0 / CAS0 ) P41 ( CS1 / CAS1 )
P42 ( CS2 / CAS2 )
P20 to P27 (A16 to A23)
The state is not changed. (does not go to high-impedance (High-Z).)
93CS40-56
2004-02-10
TMP93CS40/TMP93CS41
Figure 3.5.1 shows an example of an interface circuit using some of the pins described in Table 3.5.4, in a case when the bus releasing function is used. When the bus is released, neither internal memory nor internal I/O can be accessed. However, the internal I/O continues to operate, so the watchdog timer (WDT) also continues to run. Therefore, be careful about bus releasing time and setting of the detection time of the WDT.
P35 ( BUSAK )
3 to 5 k P42 ( CS2 )
P30 ( RD ) P31 ( WR ) P32 ( HWR ) P36 ( R/ W ) P37 ( RAS ) P40 ( CS0 ) P41 ( CS1 )
System control bus
P20 (A16) to P27 (A23)
Address bus (A23 to A16)
Figure 3.5.1 Example of an Interface Circuit using the Bus Releasing Function A circuit like the one shown above is needed to fix the signal level in the case when the bus is released. Resetting sets P30 ( RD ) and P31 ( WR ) to output; P40 ( CS0 ), P41 ( CS1 ), P32 ( HWR ), P36 ( R/ W ), P37 ( RAS ), and P35 ( BUSAK ) all to input with pull-up resistor; as well as P42 ( CS2 ) and P20 to P27 (A16 to A23) to input with pull-down resistor. A circuit like the one above is also needed to fix the signal level after resetting, because of the possibility of conflict between the external pull-up resistor and the internal pull-down resistor. The resistance of the external pull-up resistor must be 3 to 5 k, and the resistance of the internal pull-down resistor is about 50 to 150 k. Using a pull-down resistor is recommended for P20 to P27 (A16 to A23); however, if this is not possible, a switching circuit like the one used for P42 ( CS2 ) may be used.
93CS40-57
2004-02-10
TMP93CS40/TMP93CS41 3.5.1 Port 0 (P00 to P07)
Port 0 is an 8-bit general-purpose I/O port. I/O can be set on a bit basis using the control register P0CR. Resetting resets all bits of P0CR to "0", and sets port 0 to input mode. In addition to functioning as a general-purpose I/O port, port 0 also functions as an address data bus (AD0 to AD7). To access external memory, port 0 functions as an address data bus (AD0 to AD7), and all bits of the control register P0CR are cleared to "0". In the TMP93CS41, which needs external ROMs, port 0 always functions as an address data bus (AD0 to AD7) regardless of the value set in control register P0CR.
Reset
Direction control (on bit basis)
P0CR write
Internal data bus
Output latch Output buffer P0 write S Selector A P0 read B A B
Port 0 P00 to P07 (AD0 to AD7) S
Selector
Figure 3.5.2 Port 0
93CS40-58
2004-02-10
TMP93CS40/TMP93CS41 3.5.2 Port 1 (P10 to P17)
Port 1 is an 8-bit general-purpose I/O port. I/O can be set on a bit basis using control register P1CR and function register P1FC. Resetting resets all bits of output latch P1, control register P1CR, and function register P1FC to 0, and sets port 1 to input mode. In addition to functioning as a general-purpose I/O port, port 1 also functions as an address data bus (AD8 to AD15) or an address bus (A8 to A15). In the TMP93CS41, which needs external ROMs, port 1 always functions either as an address data bus (AD8 to AD15) when AM8/ AM16 = "0", or as an address bus (A8 to A15) when AM8/ AM16 = "1", regardless of the value set in control register P1CR.
Reset Direction control (on bit basis) P1CR write Function control (on bit basis)
Internal data bus
P1FC write
Output latch Output buffer P1 write S Selector A P1 read B
Port 1 P10 to P17 (AD8 to AD15/A8 to A15)
Figure 3.5.3 Port 1
93CS40-59
2004-02-10
TMP93CS40/TMP93CS41
Port 0 Register 7
P0 (0000H) Bit symbol Read/Write After reset P07
6
P06
5
P05
4
P04 R/W
3
P03
2
P02
1
P01
0
P00
Input mode (Output latch register becomes undefined.)
Port 0 Control Register 7
P0CR (0002H) Bit symbol Read/Write After reset Function 0 0 0 0 P07C
6
P06C
5
P05C
4
P04C R/W
3
P03C 0
2
P02C 0
1
P01C 0
0
P00C 0
0: Input 1: Output (when externally accessed, port 0 becomes AD7 to AD0 and P0CR is cleared to 0.)
Port 0 I/O setting 0 1 Input Output
Port 1 Register 7
P1 (0001H) Bit symbol Read/Write After reset P17
6
P16
5
P15
4
P14 R/W
3
P13
2
P12
1
P11
0
P10
Input mode (Output latch register is cleared to "0".)
Port 1 Control Register 7
P1CR (0004H) Bit symbol Read/Write After reset Function 0 0 0 0 P17C
6
P16C
5
P15C
4
P14C R/W
3
P13C 0
2
P12C 0
1
P11C 0
0
P10C 0
<>
Port 1 Function Register 7
P1FC (0005H) Bit symbol Read/Write After reset Function 0 0 0 0 P17F
6
P16F
5
P15F
4
P14F R/W
3
P13F 0
2
P12F 0
1
P11F 0
0
P10F 0
<>
Note 1: Read-modify-write is prohibited for registers P0CR, P1CR, and P1FC. Note 2: is bit X in register P1FC; is bit X in register P1CR.
Port 1 function setting
P1FC P1CR
0
1 Address data bus (AD15 to AD8) Address bus (A15 to A8)
0 1
Input port Output port
Figure 3.5.4 Registers for Ports 0 and 1
93CS40-60
2004-02-10
TMP93CS40/TMP93CS41 3.5.3 Port 2 (P20 to P27)
Port 2 is an 8-bit general-purpose I/O port. I/O can be set on a bit basis using the control register P2CR and function register P2FC. Resetting resets all bits of output latch P2, control register P2CR and function register P2FC to "0". It also sets port 2 to input mode and connects a pull-down resistor. In addition to functioning as a general-purpose I/O port, port 2 also functions as an address bus (A0 to A7) or (A16 to A23). To use port 2 as an address bus, write 1 to the output latches to turn off the programmable pull-down resistors.
A16 to A23
B Selector
A0 to A7 Reset
A
S
Direction control (on bit basis) P2CR write
Function control (on bit basis)
Internal data bus
P2FC write
S B Selector
Output latch P2 write
A Output buffer N-ch
Port 2 P20 to P27 (A0 to A7 or A16 to A23)
S Selector
B
Programmable pull down
A P2 read
Figure 3.5.5 Port 2
93CS40-61
2004-02-10
TMP93CS40/TMP93CS41
Port 2 Register 7
P2 (0006H) Bit symbol Read/Write After reset P27
6
P26
5
P25
4
P24 R/W
3
P23
2
P22
1
P21
0
P20
Input mode (Output latch register is cleared to "0".)
Port 2 Control Register 7
P2CR (0008H) Bit symbol Read/Write After reset Function 0 0 0 0 P27C
6
P26C
5
P25C
4
P24C W
3
P23C 0
2
P22C 0
1
P21C 0
0
P20C 0
<>
Port 2 Function Register 7
P2FC (0009H) Bit symbol Read/Write After reset Function 0 0 0 0 P27F
6
P26F
5
P25F
4
P24F W
3
P23F 0
2
P22F 0
1
P21F 0
0
P20F 0
<>
Note 1: Read-modify-write is prohibited for registers P2CR and P2FC. Note 2: When port P2 is used in the input mode, P2 register controls the built-in pull-down resistor. Read-modify-write is prohibited in the input mode or the I/O mode, as it may affect the states of the pull-up/pull-down resistors. Note 3: is bit X in register P2FC; is bit X in register P2CR. To set as an address bus A23 to A16, set P2FC after setting P2CR.
Port 2 function setting
P2FC P2CR
0
1 Address data bus (A7 to A0) Address bus (A23 to A16)
0 1
Input port Output port
Figure 3.5.6 Registers for Port 2
93CS40-62
2004-02-10
TMP93CS40/TMP93CS41 3.5.4 Port 3 (P30 to P37)
Port 3 is an 8-bit general-purpose I/O port. I/O can be set on a bit basis, but note that P30 and P31 are used for output only. I/O is set using control register P3CR and function register P3FC. Resetting sets all bits of output latch P3 to P1, and control register P3CR (bits 0 and 1 are unused) and function register P3FC to 0. Resetting also outputs 1 from P30 and P31, sets P32 to P37 to input mode, and connects a pull-up resistor. In addition to functioning as a general-purpose I/O port, port 3 also functions as an I/O for the CPU's control/status signal. When the P30 pin is defined as RD signal output mode ( = 1), in the TMP93CS40 or the TMP93CS41 is used, clearing the output latch register to 0 outputs the RD strobe (used for the pseudo-static RAM) from the P30 pin even when the internal address area is accessed. If the output latch register remains 1, the RD strobe signal is output only when the external address area is accessed. In the TMP93CS41, which needs external ROMs, P30 outputs the RD signal and P31 outputs the WR signal, regardless of the values set in function registers P30F and P31F.
93CS40-63
2004-02-10
TMP93CS40/TMP93CS41
Reset For TMP93CS41 Function control (on bit basis) P3FC write
Internal data bus
S Output latch P3 write
A
S Output buffer Selector
P30 ( RD ) P31 ( WR )
B
RD , WR
P3 read
Reset Direction control (on bit basis) P3CR write Function control (on bit basis) P-ch P3FC write
Programmable pull-up resistor
Internal data bus
S Output latch P3 write
A
S Output buffer Selector
P32 ( HWR ) P35 ( BUSAK ) P36 ( R/ W ) P37 ( RAS )
B
HWR , BUSAK , R/ W , RAS
S Selector
B
A P3 read
Figure 3.5.7 Port 3 (P30, P31, P32, P35, P36, P37)
93CS40-64
2004-02-10
TMP93CS40/TMP93CS41
Reset
Direction control (on bit basis) P3CR write S Output latch P3 write S Selector A Internal WAIT B P-ch Programmable pull-up resistor P33 ( WAIT ) Output buffer
Internal data bus
P3 read
Reset
Direction control (on bit basis) P3CR write Function control (on bit basis) P-ch P3FC write
Programmable pull-up resistor
Internal data bus
S Output latch P3 write
P34 ( BUSRQ )
S Selector
B
A P3 read Internal BUSRQ
Figure 3.5.8 Port 3 (P33, P34)
93CS40-65
2004-02-10
TMP93CS40/TMP93CS41
Port 3 Register 7
P3 (0007H) Bit symbol Read/Write After reset Function 1 1 1 1 Input mode (Pull up) P37
6
P36
5
P35
4
P34 R/W
3
P33 1
2
P32 1
1
P31 1
0
P30 1
Output mode
Port 3 Control Register 7
P3CR (000AH) Bit symbol Read/Write After reset Function 0 0 0: Input 0 P37C
6
P36C
5
P35C W
4
P34C 0 1: Output
3
P33C 0
2
P32C 0
1
0
I/O setting 0 Input 1 Output
Port 3 Function Register 7
P3FC (000BH) Bit symbol Read/Write After reset Function 0 0: Port 1: RAS 0 0: Port 1: R/ W P37F
6
P36F W
5
P35F 0 0: Port 1: BUSAK
4
P34F 0 0: Port 1: BUSRQ
3
2
P32F 0 0: Port 1: HWR
1
P31F W 0 0: Port 1: WR
0
P30F 0 0: Port 1: RD
Note 1: Read-modify-write is prohibited for registers P3CR and P3FC. Note 2: When port P3 is used in the input mode, the P3 register controls the built-in pull-up resistor. Read-modify-write is prohibited in the input mode or the I/O mode, as it may affect the states of the pull-up/pull-down resistors. Note 3: When the P33/WAIT pin is used as a WAIT pin, set P3CR to "0" and set the chip select/WAIT control register to "10".
P30 ( RD ) function setting

BUSRQ setting
0
1

P3FC P3CR
BUSAK setting
1 0
0
"0" output Always RD output (for pseudo SRAM)
"1" output
RD output
1 1 1
only for external access
P3FC P3CR R/ W setting P3FC P3CR
RAS setting
P31 ( WR ) function setting

0 "0" output
1 "1" output
1 1

0 1
WR output only for
external access
P3FC P3CR
1 1
HWR setting
P3FC
1
P3CR 1
Figure 3.5.9 Registers for Port 3
93CS40-66
2004-02-10
TMP93CS40/TMP93CS41 3.5.5 Port 4 (P40 to P42)
Port 4 is a 3-bit general-purpose I/O port. I/O can be set on a bit basis using control register P4CR and function register P4FC. Resetting does the following: - Sets the P40 and P41 output latch registers to 1. - Resets all bits of the P42 output latch register, the control register P4CR, and the function register P4FC to 0. - Sets P40 and P41 to input mode and connects a pull-up resistor. - Sets P42 to input mode and connects a pull-down resistor. In addition to functioning as a general-purpose I/O port, port 4 also functions as a chip select output signal ( CS0 to CS2 or CAS0 to CAS2 ).
93CS40-67
2004-02-10
TMP93CS40/TMP93CS41
Reset Direction control (on bit basis) P4CR write Function control (on bit basis) P-ch P4FC write
Programmable pull-up resistor
Internal data bus
S Output latch P4 write
A
S Selector Output buffer
P40 ( CS0 / CAS0 ) P41 ( CS1 / CAS1 )
B
CS0 / CAS0
,
CS1 / CAS1
S Selector
B
A P4 read
Reset
Direction control (on bit basis) P4CR write Function control (on bit basis) P4FC write
Internal data bus
R Output latch P4 write
A
S Output buffer Selector N-ch
P42 ( CS2 / CAS2 )
B
CS2 / CAS2
Programmable pull-down resistor
S Selector
B
A P4 read
Figure 3.5.10 Port 4
93CS40-68
2004-02-10
TMP93CS40/TMP93CS41
Port 4 Register 7
P4 (000CH) Bit symbol Read/Write After reset Function
0 (Pull down)
6
5
4
3
2
P42
1
P41 R/W Input mode
1 (Pull up)
0
P40
1 (Pull up)
Port 4 Control Register 7
P4CR (000EH) Bit symbol Read/Write After reset Function 0 0: Input
6
5
4
3
2
P42C
1
P41C W 0 1: Output
0
P40C 0
I/O setting 0 1 Input Output
Port 4 Function Register 7
P4FC (0010H) Bit symbol Read/Write After reset Function 0 0: Port
6
5
4
3
2
P42F
1
P41F W
0
P40F
0 0 1: CS / CAS
Note 1: Read-modify-write is prohibited for registers P4CR and P4FC. Note 2: When port P4 is used in the input mode, the P4 register controls the built-in pull-up/pull-down resistor. Read-modify-write is prohibited in the input mode or the I/O mode, as it may affect the states of the pull-up/pull-down resistors. Note 3: To output chip select signal ( CS0 / CAS0 to CS2 / CAS2 ), set the corresponding bits of the control register P4CR and the function register P4FC to "1". Chip select/wait controller (B0CS, B1CS, B2CS) registers select the function of CS / CAS . Note 4: P4 are always read as "1".
0 1 0 1 0 1
Port (P40) CS0 / CAS0 Port (P41) CS1 / CAS1 Port (P42) CS2 / CAS2
Figure 3.5.11 Registers for Port 4
93CS40-69
2004-02-10
TMP93CS40/TMP93CS41 3.5.6 Port 5 (P50 to P57)
Port 5 is an 8-bit input port, also used as an analog input pin for the internal AD converter.
Internal data bus
Port 5 P50 to P57 Port 5 read (AN0 to AN7)
Conversion result register AD read
AD converter
Channel selector
Figure 3.5.12 Port 5 Port 5 Register 7
P5 (000DH) Bit symbol Read/Write After reset P57
6
P56
5
P55
4
P54 R
3
P53
2
P52
1
P51
0
P50
Input mode
Note: The input channel selection of the AD converter is set by AD converter mode register ADMOD2.
Figure 3.5.13 Registers for Port 5
93CS40-70
2004-02-10
TMP93CS40/TMP93CS41 3.5.7 Port 6 (P60 to P67)
Port 6 is an 8-bit general-purpose I/O port. I/O can be set on a bit basis. Resetting sets port 6 as an input port and connects a pull-up resistor. It also sets all bits of the output latch to 1. In addition to functioning as a general-purpose I/O port, port 6 also functions as a pattern generator of PG0 or PG1 output. PG0 is assigned to P60 to P63; PG1, to P64 to P67. Writing 1 in the appropriate bit of the port 6 function register (P6FC) enables PG output. Resetting resets the function register P6CR, P6FC value to "0", and sets all bits to input ports.
Reset
Direction control (on bit basis) P6CR write Function control (on bit basis) P6FC write
Internal data bus
S Output latch P6 write PG0, 1
A
S Selector
P-ch Programmable pull up Port 6 P60 to P67 (PG00 to PG13)
B
S Selector
B
A P6 read
Figure 3.5.14 Port 6
93CS40-71
2004-02-10
TMP93CS40/TMP93CS41
Port 6 Register 7
P6 (0012H) Bit symbol Read/Write After reset Function 1 1 1 1 P67
6
P66
5
P65
4
P64 R/W
3
P63 1
2
P62 1
1
P61 1
0
P60 1
Input mode (Pull up)
Port 6 Control Register 7
P6CR (0014H) Bit symbol Read/Write After reset Function 0 0 0 0 0: Input P67C
6
P66C
5
P65C
4
P64C W
3
P63C 0 1: Output
2
P62C 0
1
P61C 0
0
P60C 0
Port 6 I/O setting 0 1 Input Output
Port 6 Function Register 7
P6FC (0016H) Bit symbol Read/Write After reset Function 0 0 0: Port 0 1: PG1-OUT 0 P67F
6
P66F
5
P65F
4
P64F W
3
P63F 0
2
P62F 0 0: Port
1
P61F 0 1: PG0-OUT
0
P60F 0
Port 6 function setting 0 Note 1: Read-modify-write is prohibited for registers P6CR and P6FC. Note 2: When port P6 is used in the input mode, the P6 register controls the built-in pull-up resistor. Read-modify-write is prohibited in the input mode or the I/O mode, as it may affect the states of the pull-up/pull-down resistors. 1 General-purpose port Stepping motor control/pattern generation port
Figure 3.5.15 Registers for Port 6
93CS40-72
2004-02-10
TMP93CS40/TMP93CS41 3.5.8 Port 7 (P70 to P73)
Port 7 is a 4-bit general-purpose I/O port. I/O can be set on a bit basis. Resetting sets port 7 as an input port and connects a pull-up resistor. In addition to functioning as a general-purpose I/O port, port 70 also functions as an input clock pin TI0; port 71 as an 8-bit timer output (TO1), port 72 as a PWM0 output (TO2), and port 73 as a PWM1 output (TO3) pin. Writing 1 in the corresponding bit of the port 7 function register (P7FC) enables output of the timer. Resetting resets the function register P7CR, P7FC value to 0, and sets all bits to input ports.
Reset Direction control (on bit basis) P7CR write S Output latch P-ch Programmable pull up P70 (TI0)
P7 write S B Selector P7 read TI0 Reset A
Internal data bus
Direction control (on bit basis) P7CR write Function control (on bit basis) P7FC write S Output latch P7 write Timer F/F out TO1: Timer 1 TO2: Timer 2 TO3: Timer 3 B Selector A B
A
S Selector
P-ch Programmable pull up P71 to P73 (TO1 to TO3)
P7 read
S
Figure 3.5.16 Port 7
93CS40-73
2004-02-10
TMP93CS40/TMP93CS41
Port 7 Register 7
P7 (0013H) Bit symbol Read/Write After reset Function 1 1
6
5
4
3
P73
2
P72 R/W
1
P71 1
0
P70 1
Input mode (Pull up)
Port 7 Control Register 7
P7CR (0015H) Bit symbol Read/Write After reset Function 0 0 0: Input
6
5
4
3
P73C
2
P72C W
1
P71C 0 1: Output
0
P70C 0
Port 7 I/O setting 0 1 Input Output
Port 7 Function Register 7
P7FC (0017H) Bit symbol Read/Write After reset Function 0 0: Port 1: TO3
6
5
4
3
P73F
2
P72F W 0 0: Port 1: TO2
1
P71F 0 0: Port 1: TO1
0
Setting P71 as TO1 P7FC P7CR Note 1: Read-modify-write is prohibited for registers P7CR and P7FC. Note 2: When port P7 is used in the input mode, the P7 register controls the built-in pull-up resistor. Read-modify-write is prohibited in the input mode or the I/O mode, as it may affect the states of the pull-up/pull-down resistors. Note 3: The P70/T10 pin does not have a register changing it from port to function. For example, when it is used as an input port, the incoming signal is input to 8-bit timer 0 as a timer input 0 (T10). Note 4: P7 are always read as "1". Setting P73 as TO3 P7FC P7CR 1 1 Setting P72 as TO2 P7FC P7CR 1 1 1 1
Figure 3.5.17 Registers for Port 7
93CS40-74
2004-02-10
TMP93CS40/TMP93CS41 3.5.9 Port 8 (P80 to P87)
Port 8 is an 8-bit general-purpose I/O port. I/O can be set on a bit basis. Resetting sets port 8 as an input port and connects a pull-up resistor. It also sets all bits of the output latch register P8 to 1. In addition to functioning as a general-purpose I/O port, port 8 also functions as an input for 16-bit timer 4 and 5 clocks, an output for 16-bit timer F/F 4, 5, and 6 output, and an input for INT0. Writing "1" in the corresponding bit of the port 8 function register (P8FC) enables those functions. Resetting resets the function register P8CR, P8FC value to "0" and sets all bits to input ports. (1) P80 to P86
Reset Direction control (on bit basis) P8CR write S Output latch P8 write S B Selector P8 read TI4, TI5 TI6, TI7 A P-ch Programmable pull up P80 (TI4/INT4) P81 (TI5/INT5) P84 (TI6/INT6) P85 (TI7/INT7)
Reset
Internal data bus
Direction control (on bit basis) P8CR write Function control (on bit basis) P8FC write S Output latch P8 write Timer F/F out TO4: Timer 4 TO5: Timer 4 TO6: Timer 5 B Selector A B Programmable pull up
P-ch A S Selector
P82 (TO4) P83 (TO5) P86 (TO6)
P8 read
S
Figure 3.5.18 Port 8 (P80 to P86)
93CS40-75
2004-02-10
TMP93CS40/TMP93CS41
(2) P87 (INT0) Port 87 is a general-purpose I/O port, and is also used as an INT0 pin for external interrupt request input.
Reset Direction control (on bit basis) P8CR write S Output latch P8 write S B Selector P8 read A P-ch Programmable pull-up resistor P87 (INT0)
Internal data bus
INT0 interrupt
Level/edge detect
IIMC
IIMC
Figure 3.5.19 Port 87
93CS40-76
2004-02-10
TMP93CS40/TMP93CS41
Port 8 Register 7
P8 (0018H) Bit symbol Read/Write After reset Function 1 1 1 1 P87
6
P86
5
P85
4
P84 R/W
3
P83 1
2
P82 1
1
P81 1
0
P80 1
Input mode
Port 8 Control Register 7
P8CR (001AH) Bit symbol Read/Write After reset Function 0 0 0 0: Input 0 P87C
6
P86C
5
P85C
4
P84C W
3
P83C 0 1: Output
2
P82C 0
1
P81C 0
0
P80C 0
Port 8 I/O setting 0 1 Input Output
Port 8 Function Register 7
P8FC (001CH) Bit symbol Read/Write After reset Function
6
P86F W 0 0: Port 1: TO6
5
4
3
P83F W 0 0: Port 1: TO5
2
P82F W 0 0: Port 1: TO4
1
0
Setting P82 as TO4 Note 1: Read-modify-write is prohibited for registers P8CR and P8FC. Note 2: When port P8 is used in the input mode, the P8 register controls the built-in pull-up resistor. Read-modify-write is prohibited in the input mode or the I/O mode, as it may affect the states of the pull-up/pull-down resistors. Note 3: The P80/TI4, P81/TI5, P84/TI6, and P85/TI7 pins do not have a register changing them from port to function. For example, when they are used as an input port, the incoming signal is input to the 16-bit timer as timer input. When P87/INT0 pin is used as an INT0 pin, set P8CR to "0" and IIMC to "1". P8FC P8CR 1 1
Setting P83 as TO5 P8FC P8CR 1 1
Setting P86 as TO6 P8FC P8CR 1 1
Figure 3.5.20 Registers for Port 8
93CS40-77
2004-02-10
TMP93CS40/TMP93CS41 3.5.10 Port 9 (P90 to P97)
* Ports 90 to 95 Ports 90 to 95 constitute a 6-bit general-purpose I/O ports. I/Os can be set on a bit basis. Resetting sets P90 to P95 to an input port and connects a pull-up resistor. It also sets all bits of the output latch register to 1. In addition to functioning as a general-purpose I/O port, P90 to P95 can also function as an I/O for serial channels 0 and 1. Writing "1" in the corresponding bit of the port 9 function register (P9FC) enables those functions. Resetting resets the function register P9CR, P9FC value to "0" and sets all bits to input ports. * Ports 96 to 97 Ports 96 to 97 form a 2-bit general-purpose I/O port. I/Os can be set on a bit basis. The output buffer for P96 to P97 is an open-drain type buffer. Resetting sets the output latch and control registers to "1" and outputs high-impedance (High-Z). In addition to functioning as a general-purpose I/O port, P96 to P97 can also function as a low-frequency oscillator connecting pin for dual clock mode. The dual clock function can be set by programming system clock control register SYSCR0 and 1. (1) Ports 90, 93 (TXD0/TXD1) Ports 90 and 93 also function as serial channel TXD output pins in addition to I/O ports. They have a programmable open-drain function.
93CS40-78
2004-02-10
TMP93CS40/TMP93CS41
Reset
Direction control (on bit basis) P9CR write Function control (on bit basis) P9FC write
Internal data bus
S Output latch P9 write TXD0, TXD1
A
S Selector
P-ch Programmable pull-up resistor P90 (TXD0) Open-drain possible ODE P93 (TXD1)
B
S Selector
B
A P9 read
Figure 3.5.21 Ports 90 and 93 (2) Port 91, 94 (RXD0, RXD1) Ports 91 and 94 are I/O ports, and are also used as RXD input pins for serial channels.
Reset
Direction control (on bit basis) P9CR write P-ch Programmable pull-up resistor P91 (RXD0) P94 (RXD1)
Internal data bus
S Output latch P9 write S B Selector P9 read RXD0, RXD1 A
Figure 3.5.22 Ports 91 and 94
93CS40-79
2004-02-10
TMP93CS40/TMP93CS41
(3) Port 92 ( CTS0 /SCLK0) Port 92 is an I/O port, and is also used as a CTS0 input pin and as a SCLK0 I/O pin for serial channels.
Reset
Direction control (on bit basis) P9CR write Function control (on bit basis) P9FC write
Internal data bus
S Output latch A P9 write Selector SCLK0 B S
P-ch Programmable pull-up resistor
P92 (SCLK0/ CTS0 )
S Selector P9 read
CTS0
B
A
SCLK0
Figure 3.5.23 Port 92
93CS40-80
2004-02-10
TMP93CS40/TMP93CS41
(4) Port 95 (SCLK1) Port 95 is a general-purpose I/O port. It is also used as a SCLK1 I/O pin for serial channel 1.
Reset
Direction control (on bit basis) P9CR write Function control (on bit basis) P9FC write
Internal data bus
S Output latch A P9 write Selector SCLK1 B S
P-ch Programmable pull-up resistor
P95 (SCLK1)
S Selector P9 read SCLK1
B
A
Figure 3.5.24 Port 95
93CS40-81
2004-02-10
TMP93CS40/TMP93CS41
(5) Port 96 (XT1), 97 (XT2) Ports 96 and 97 are general purpose I/O ports. They are also used as low-frequency oscillator connecting pins.
Reset Bus 6 S Direction control (on bit basis) P9CR write Bus 6 S Output latch P9 write S Bus 6 Selector B Low-frequency oscillation enable
P96 (XT1) Output buffer
(Open-drain output)
Internal data bus
P9 read
A
(ON at "1")
Bus 7
S Direction control (on bit basis) P9CR write
Bus 7
S Output latch P9 write S
P97 (XT2) Output buffer
(Open-drain output)
Low-frequency clock (fs) B
Bus 7 Selector P9 read A
Figure 3.5.25 Ports 96 and 97
93CS40-82
2004-02-10
TMP93CS40/TMP93CS41
Port 9 Register 7
P9 (0019H) Bit symbol Read/Write After reset Function Output mode 1 1 1 1 1 P97
6
P96
5
P95
4
P94 R/W
3
P93
2
P92
1
P91
0
P90
Input mode 1 1 1
Port 9 Control Register 7
P9CR (001BH) Bit symbol Read/Write After reset Function 1 1 0 0: Input 0 P97C
6
P96C
5
P95C
4
P94C W
3
P93C 0 1: Output
2
P92C 0
1
P91C 0
0
P90C 0
Port 9 I/O setting Note: Port 96 and 97's output buffer is an open-drain output type. 0 1 Input Output
Port 9 Function Register 7
P9FC (001DH) Bit symbol Read/Write After reset Function
6
5
P95F W 0 0: Port 1: SCLK1
4
3
P93F W 0 0: Port 1: TXD1
2
P92F W 0 0: Port 1: SCLK0
1
0
P90F W 0 0: Port 1: TXD0
P90 TXD0 output setting (Note 3) Note 1: Read-modify-write is prohibited for registers P9CR and P9FC. Note 2: When port P9 is used in the input mode, the P9 register controls the built-in pull-up resistor. Read-modify-write is prohibited in the input mode or the I/O mode, as it may affect the states of the pull-up/pull-down resistors. Note 3: When the TXD pin is set to be an open-drain output type, set 1 to bit0 (for TXD0 pin) or bit1 (for TXD1 pin) of the ODE register. The P91/RXD0 and P94/RXD1 pins do not have a register changing them from port to function. For example, when they are used as an input port, the incoming signal is input to the SIO as serial receiving data. P9FC P9CR 1 1
P92 SCLK0 output setting P9FC P9CR 1 1
P93 TXD1 output setting (Note 3) P9FC P9CR 1 1
P95 SCLK1 output setting P9FC P9CR 1 1
Note 4: Notes on using low-frequency oscillation circuit. To connect a low-frequency resonator to ports 96 and 97, it is necessary to set the following procedures to reduce the consumption of power. (Connecting to a resonator) Set P9CR = "11", P9 = "00" (Connecting to an oscillator) Set P9CR = "11", P9 = "10" Note5: When ports 96 and 97 is used in the output mode, input gate in operation. Set output to "L" or attach pull-up on pin to reduce the consumption of power, before the HALT instruction is executed.
Figure 3.5.26 Registers for Port 9
93CS40-83
2004-02-10
TMP93CS40/TMP93CS41 3.5.11 Port A (PA0 to PA7)
Port A is an 8-bit general-purpose I/O port. I/Os can be set on a bit basis by control register PACR. Resetting sets port A to an input port by resetting PACR. It also sets all bits of the output latch register to "1". In addition to functioning as a general-purpose I/O port (Only PA7), PA7 can also function as an internal clock output pin. The output clock is fFPH or fSYS that is selected as oscillator output clock. It is selected by CKOCR. The SCOUT function is enabled by setting PACR and CKOCR.
Reset R Direction control (on bit basis) PACR write S Output latch PA write S Selector PA read A B
Internal data bus
PA0 to PA6
Figure 3.5.27 Port A0 to A6
93CS40-84
2004-02-10
TMP93CS40/TMP93CS41
Reset BUS 7 R Direction control (on bit basis) PACR write BUS 2 R Function control (on bit basis) CKOCR write
Internal data bus
BUS 7
S Output latch PA write
A
S Selector PA7 (SCOUT)
B
S Selector
B
BUS 7
A PA read
fFPH
A Selector
fSYS
B
S
CKOCR
Figure 3.5.28 Port A7
93CS40-85
2004-02-10
TMP93CS40/TMP93CS41
Port A Register 7
PA (001EH) Bit symbol Read/Write After reset Function 1 1 1 1 Input mode PA7
6
PA6
5
PA5
4
PA4 R/W
3
PA3 1
2
PA2 1
1
PA1 1
0
PA0 1
Port A Control Register 7
PACR (001FH) Bit symbol Read/Write After reset Function 0 0 0 0 0: Input PA7C
6
PA6C
5
PA5C
4
PA4C W
3
PA3C 0 1: Output
2
PA2C 0
1
PA1C 0
0
PA0C 0
Clock Output Control Register 7
CKOCR (006DH) Bit symbol Read/Write After reset Function 0 0
6
5
4
3
SCOSEL
2
SCOEN R/W
1
ALEEN 0/1
0
CLKEN 0/1
Clock select Clock enable ALE enable CLK enable
Note 1: Read-modify-write is prohibited for registers PACR. Note 2: The value after reset of , is following: TMP93CS40: "0" (High-impedance output) TMP93CS41: "1" (CLK or ALE output) But during reset, the CLK pin is pulled up internally regardless of which of these two microcontrollers is in use. Note 3: The output clock from the SCOUT pin is as fFPH or fSYS clock signal. e.g. The case of a 20 MHz oscillator connected to the X1 and X2 pins. = "0" 20 MHz clock = "1" 10 MHz clock
CLK pin output control (Note 1)
0 1
High impedance CLK output
ALE pin output control (Note 1)
0 1
High impedance ALE output
SCOUT/PA7 pin control PACR 0
0
1
0 1 0 1 Input Port
Output mode fFPH clock output (Note 3) fSYS clock output (Note 3)
1
Figure 3.5.29 Registers for Port A
93CS40-86
2004-02-10
TMP93CS40/TMP93CS41
3.6
Chip Select/Wait Controller, AM8/ AM16 pin
The TMP93CS40 and TMP93CS41 have a built-in chip select/wait controller used to control chip select ( CS0 to CS2 pins), wait ( WAIT pin), and data bus size (8 or 16 bits) for any of the three block address areas. In addition, the AM8/ AM16 pin selects external data bus width.
3.6.1
AM8/ AM16 pin
(1) Usage in the TMP93CS40 Set this pin to "1". After resetting, the CPU accesses the internal ROM with 16-bit bus width. The bus width when the CPU accesses an external area is set by the chip select/wait control register (described in section 3.6.3), P1CR and P1FC. (If this pin is set to 1, that value will be ignored and the value set by register will be active.) (2) Usage in the TMP93CS41 (2-1) When 16-bit bus width and 8-bit bus width are both used, or when 16-bit bus width only is used: Set this pin to "0". Then the AD8 to AD15 or A8 to A15 pins of port 1 are fixed to their A8 to A15 function compulsorily, and the values of P1CR and P1FC are ignored. The bus width when the CPU accesses an external area is set by the chip select/wait control register described in section 3.6.2. After a reset, 16-bit external program memory must be accessed before any other memory is accessed. (2-2) When 8-bit bus width only is used: Set this pin to "1". Then the AD8 to AD15 or A8 to A15 pins of port 1 are fixed to their A8 to A15 function compulsorily, and the values of P1CR and P1FC are ignored. The values of bit4 in , , or , described in section 3.6.3, are ignored and the bus width is fixed to 8 bits.
93CS40-87
20004-02-10
TMP93CS40/TMP93CS41 3.6.2 Address/Data Bus Pins
Port 0, port 1 and port 2 function as an address and data bus for connecting the microcontroller to the external memories and I/O peripherals.
1.
Products Number of Address Bus Pins Number of Data Bus Pins Number of Multiplexed Pins Mode Pins
EA
2.
TMP93CS41F (Note 4)
3.
4.
TMP93CS40F (Note 2), (Note 3) max16 (to 64 Kbytes) 8 0 VIH VIL VIH AD0 to AD7 A8 to A15 A0 to A7
A15 to A0 AD7 to AD0 ALE
A15 to A0 (Note 1) A7 D7 to A0 to D0
max24 (to 16 Mbytes) 8 8 VIL VIH AD0 to AD7 A8 to A15 A16 to A23
A23 to A8 AD7 to AD0 ALE
A23 to A8 A7 to A0 D7 to D0
max24 (to 16 Mbytes) 16 16
max8 (to 256 Kbytes) 16 0
AM8/ AM16 Port 0
AD0 to AD7 AD8 to AD15 A16 to A23
A23 to A16 AD15 to AD0 ALE
A23 to A16 A15 to A0 D15 to D0
AD0 to AD7 AD8 to AD15 A0 to A7
A7 to A0 AD15 to AD0 ALE
A7 to A0 (Note 1) A15 D15 to A0 to D0
Port Function
Port 1 Port 2
Timing Chart
RD
RD
RD
RD
Note 1: In the cases of 3. and 4., the data bus signals output the addresses because the signals are also used as the address bus. By writing "0" to bit CKOCR, the ALE signal can be prevented from outputting. Note 2: After a reset operation, port 0, port 1, and port 2 of the TMP93CS40F function as input ports. Note 3: In the case of the TMP93CS40F, all the options a. to d. can be made available using the P1CR, P1FC, P2CR, and P2FC registers. ( EA = VIH, AM8/ AM16 = VIH) Note 4: In the case of the TMP93CS41F, options 3. and 4. cannot be made available.
93CS40-88
20004-02-10
TMP93CS40/TMP93CS41 3.6.3 Control Registers
Table 3.6.1 shows control registers. One block of the address areas is controlled by each of the 1-byte CS/WAIT control registers B0CS, B1CS, and B2CS. (1) Master enable bits Bit7 of the control registers (B0E, B1E, and B2E) are master bits used to specify setting enable (1) or disable (0). Resetting sets B0E and B1E to disable (0) and B2E to enable (1). (2) CS/CAS waveform select Bit5 of the control registers (B0CAS, B1CAS, and B2CAS) are used to specify the waveform mode output from the chip select pin (from CS0 to CS2 , or from CAS0 to CAS2 ). Setting these bits to 0 specifies CS0 to CS2 waveforms; setting them to 1 specifies CAS0 to CAS2 waveforms. Resetting clears bits 5 to 0. (3) Data bus size select Bit4 (B0BUS, B1BUS, and B2BUS) of the control register is used to specify data bus size. Setting this bit to 0 accesses the memory in 16-bit data bus mode; setting it to 1 accesses the memory in 8-bit data bus mode. Changing data bus size depending on the access address is called dynamic bus sizing. Table 3.6.2 shows the details of the bus operation. This bit is changed by changing the state of the AM8/ AM16 pin. (4) Wait control Control register bits 3 and 2 are used to specify the number of waits. Setting these bits to 00 inserts a 2-state wait regardless of the WAIT pin status. Setting them to 01 inserts a 1-state wait regardless of the WAIT status. Setting them to 10 inserts a 1-state wait and samples the WAIT pin status. If the pin is Low, inserting the wait maintains the bus cycle until the pin goes high. Setting them to 11 completes the bus cycle without a wait, regardless of the WAIT pin status. Resetting sets these bits to 00 (2-state wait mode).
93CS40-89
20004-02-10
TMP93CS40/TMP93CS41
(5) Address area specification Control register bits 1 and 0 are used to specify the target address area. Setting these bits to 00 enables settings (e.g., CS output, wait state, and bus size) as follows: * The CS0 setting is enabled when the address space 7F00H to 7FFFH is accessed. * The CS1 setting is enabled when the address space 880H to 7FFFH is accessed. * The CS2 setting is enabled when the address space 8000H to 3FFFFFH is accessed in the TMP93CS41, which does not have a built-in ROM. The CS2 setting is enabled when the address space 18000H to 3FFFFFH is accessed in the TMP93CS40, which has built-in ROM. Setting these bits to 01 enables settings ( CS output, wait state...) for all CS's blocks and outputs a low strobe signal (from CS0 to CS2 , or from CAS0 to CAS2 ) from the chip select pins when the address space 400000H to 7FFFFFH is accessed. Setting these bits to 10 enables the address space 800000H to BFFFFFH to be accessed. Setting these bits to 11 enables the address space C00000H to FFFFFFH to be accessed. Table 3.6.1 Chip Select/Wait Control Register
Code Name Address 7 B0E Block0 CS/WAIT control register W 0 0068H
1: Master bit of bit0 to 6
6
5 B0CAS W 0 0: CS0 1: CAS0
4 B0BUS W 0 0: 16-bit bus 1: 8-bit bus B1BUS W 0 0: 16-bit bus 1: 8-bit bus B2BUS W 0 0: 16-bit bus 1: 8-bit bus
3 B0W1 W 0
2 B0W0 W 0
1 B0C1 W 0
0 B0C0 W 0
B0CS
00: 2 waits 01: 1 wait 10: (1 + n) waits 11: 0 waits B1W1 W 0 B1W0 W 0
00: 7F00H to 7FFFH 01: 400000H to 10: 800000H to 11: C00000H to B1C1 W 0 B1C0 W 0
B1E Block1 CS/WAIT control register W 0 0069H
1: Master bit of bit0 to 6
B1CAS W 0 0: CS1 1: CAS1
B1CS
00: 2 waits 01: 1 wait 10: (1 + n) waits 11: 0 waits B2W1 W 0 B2W0 W 0
00: 880H to 7FFFH 01: 400000H to 10: 800000H to 11: C00000H to B2C1 W 0 00: 8000H to 01: 400000H to 10: 800000H to 11: C00000H to B2C0 W 0
B2E Block2 CS/WAIT control register W 1 006AH
1: Master bit of bit0 to 6
B2CAS W 0 0: CS2 1: CAS2
B2CS
00: 2 waits 01: 1 wait 10: (1 + n) waits 11: 0 waits
Note: Read-modify-write is prohibited for B0CS, B1CS, and B2CS.
93CS40-90
20004-02-10
TMP93CS40/TMP93CS41
Table 3.6.2 Dynamic Bus Sizing Operand Data Operand Start Memory Data CPU Address Size Address Size
8 bits 2n + 0 (Even number) 2n + 1 (Odd number) 16 bits 2n + 0 (Even number) 16 bits 2n + 1 (Odd number) 16 bits 32 bits 2n + 0 (Even number) 8 bits 8 bits 8 bits 16 bits 8 bits 16 bits 8 bits 2n + 0 2n + 0 2n + 1 2n + 1 2n + 0 2n + 1 2n + 0 2n + 1 2n + 2 2n + 1 2n + 2 2n + 0 2n + 1 2n + 2 2n + 3 2n + 0 2n + 2 2n + 1 2n + 2 2n + 3 2n + 4 2n + 1 2n + 2 2n + 4
CPU Data D15 to D8
xxxxx xxxxx xxxxx b7 to b0 xxxxx xxxxx b15 to b8 xxxxx xxxxx b7 to b0 xxxxx xxxxx xxxxx xxxxx xxxxx b15 to b8 b31 to b24 xxxxx xxxxx xxxxx xxxxx b7 to b0 b23 to b16 xxxxx
D7 to D0
b7 to b0 b7 to b0 b7 to b0 xxxxx b7 to b0 b15 to b8 b7 to b0 b7 to b0 b15 to b8 xxxxx b15 to b8 b7 to b0 b15 to b8 b23 to b16 b31 to b24 b7 to b0 b23 to b16 b7 to b0 b15 to b8 b23 to b16 b31 to b24 xxxxx b15 to b8 b31 to b24
16 bits 2n + 1 (Odd number) 8 bits
16 bits
xxxxx: During a read, data input to the bus is ignored. While writing, the bus is at high impedance and the write strobe signal remains in active.
93CS40-91
20004-02-10
TMP93CS40/TMP93CS41 3.6.4 Chip Select Addresses Image
An image of the actual addresses which can be specified by chip select is shown below. Out of the whole memory area, address areas that can be specified are divided into four parts. Addresses from 000000H to 3FFFFFH are further divided as follows: 7F00H to 7FFFH is specified for CS0; 880H to 7FFFH, for CS1; and 8000H to 3FFFFFH, for CS2. The reason is that a device other than ROM (e.g., RAM or I/O) might be connected externally. 7F00 to 7FFFH (256 bytes) designated as CS0 are mapped mainly for possible expansions to external I/O. 880H to 7FFFH (approx. 31 Kbytes) designated as CS1 are mapped mainly for possible extensions to external RAM. 8000H to 3FFFFFH (approx. 4 Mbytes) designated as CS2 are mapped mainly for possible extensions to external ROM. After resetting, CS2 is enabled in a 16-bit bus and 2-wait configuration. In the case of the TMP93CS41, which does not have a built-in ROM, the program is externally read at address 8000H with these settings (16-bit bus, 2 waits). With the TMP93CS40, which does have a built-in ROM, addresses from 8000H to 17FFFH are used as the internal ROM area; CS2 is disabled in this area. After resetting, the CPU reads the program from the built-in ROM in 16-bit bus, 0-wait mode.
CS0 CS1 CS2
000000H 7F00H 8000H 400000H B0C1, 0 = "01" 800000H B0C1, 0 = "10" C00000H B0C1, 0 = "11" FFFFFFH (Mainly for I/O) (Mainly for RAM) (Mainly for ROM) B1C1, 0 = "11" B2C1, 0 = "11" B1C1, 0 = "10" B2C1, 0 = "10" B1C1, 0 = "01" B2C1, 0 = "01" B0C1, 0 = "00" B1C1, 0 = "00" B2C1, 0 = "00"
Note 1: Note 2:
Access priority is highest for built-in I/O, then built-in memory, and lowest for the chip select/wait controller. External areas other than CS0 to CS2 are accessed in 0 wait mode. For the TMP93CS40, the data bus width is fixed at 16 bits. For the TMP93CS41, the data bus width is 16 bits when AM8/ AM16 = 0, and 8 bits when AM8/ AM16 = 1. When using the chip select/wait controller, do not specify the same address area more than once. (However, when specifications overlap, only one of them will be utilized. For example, when addresses 7F00H to 7FFFH for CS0 are specified at the same time as 880H to 7FFFH for CS1, only the CS0 setting and pin will be active.)
Note 3:
When the bus is released ( BUSAK = "0"), the CS0 to CS2 pins are also released (the output buffer is OFF). For further information about the state of pins, refer to the note about the bus release in section 3.5 "Functions of Ports".
93CS40-92
20004-02-10
TMP93CS40/TMP93CS41 3.6.5 Example of Usage
(1) Example of usage -1 Figure 3.6.1 is an example in which an external memory is connected to the TMP93CS41. In this example, a ROM is connected using a 16-bit bus; a RAM is connected using an 8-bit bus.
74HC573 D TMP93CS41
CS0 CS1 CS2
Q LE
CS
Address Bus
D LE
Q
Upper byte ROM
CS
Lower byte ROM
CS
8-bit bus RAM
CS
8-bit bus I/O
OE
OE
OE WE
OE WE
ALE AD8 to AD15
EA
AD0 to AD7
AM8/ AM16
RD WR
Figure 3.6.1 Example of External Memory Connection (ROM = 16 bits, RAM and I/O = 8 bits) Resetting sets pins CS0 to CS2 to input port mode. CS0 and CS1 are set high due to an internal pull-up resistor; CS2 is set low due to an internal pull-down resistor. The program used to set these pins is as follows.
P4CR P4FC B0CS B1CS B2CS LD LD LD LD LD
EQU 0EH EQU 10H EQU 68H EQU 69H EQU 6AH (B0CS), 1X010000B (B1CS), 1X011100B (B2CS), 1X000100B (P4CR), XXXXX111B (P4FC), XXXXX111B
; CS0 = 8 bits, 2 waits, 7F00H to 7FFFH ; CS1 = 8 bits, 0 waits, 880H to 7EFFH ; CS2 = 16 bits, 1 wait, 8000H to 3FFFFFH
CS0 , CS1 , CS2 output mode setting
X: Don't care
93CS40-93
20004-02-10
TMP93CS40/TMP93CS41
(2) Example of usage -2 Figure 3.6.2 is an example in which an external memory is connected to the TMP93CS41. In this example, a ROM, RAM, and I/O are each connected using an 8-bit bus.
Address bus TMP93CS41
CS0 CS1 CS2
74HC573
CS
D LE
Q
OE
8-bit bus ROM
CS
8-bit bus RAM
CS
8-bit bus I/O
OE WE
OE WE
ALE A8 to A15
EA
AD0 to AD7
RD WR
AM8/ AM16
Figure 3.6.2 Example of External Memory Connection (ROM, RAM and I/O = 8 Bits) Resetting sets pins CS0 to CS2 to input port mode. CS0 and CS1 are set high due to an internal pull-up resistor; CS2 is set low due to an internal pull-down resistor. The program used to set these pins is as follows.
P4CR P4FC B0CS B1CS B2CS LD LD LD LD LD EQU 0EH EQU 10H EQU 68H EQU 69H EQU 6AH (B0CS), 1X010000B (B1CS), 1X011100B (B2CS), 1X000100B (P4CR), XXXXX111B (P4FC), XXXXX111B
; CS0 = 8 bits, 2 waits, 7F00H to 7FFFH ; CS1 = 8 bits, 0 waits, 880H to 7EFFH ; CS2 = 8 bits, 1 wait, 8000H to 3FFFFFH
CS0 , CS1 , CS2 output mode setting
X: Don't care
93CS40-94
20004-02-10
TMP93CS40/TMP93CS41
(3) Example of usage -3 Figure 3.6.3 is an example in which an external memory is connected to the TMP93CS40. In this example, a 128-Kbyte ROM is connected using a 16-bit bus, and a 256-Kbyte RAM is connected using a 16-bit bus.
TMP93CS40
A16 to A17 AD8 to AD15
Latch x 16
D Q LE A16 A1 to A15
ROM (128 Kbits x 16) A15 A0 to A14
OE CE
D8 to D15 D0 to D7
AD0 to AD7 ALE
CS2
RAM (128 Kbits x 8)
A16 to A17
A1 to A15
A15 to A16 A0 to A14
OE
I/O1 to 8
RD
HWR
R/ W
CE 1
Upper byte
CS1 WR
RAM (128 Kbits x 8)
A16 to A17 A1 to A15
A15 to A16 A0 to A14
OE R/ W CE 1
I/O1 to 8
AM8/ AM16
EA
Lower byte
Figure 3.6.3 Example of External Memory Connection (ROM & RAM = 16 bits) The TMP93CS40 has built-in ROM and RAM. When ROM and RAM have insufficient capacity, it is possible to connect an external memory following the usage examples for this purpose. In this example, the memory configuration is as follows. Memory
ROM SRAM Internal External Internal External
Memory Size
64 Kbytes 128 Kbytes 2 Kbytes 256 Kbytes
Address
008000H to 017FFFH 400000H to 41FFFFH 000080H to 00087FH 800000H to 83FFFFH
CS Pin
-
CS2
Data Bus
16 bits 16 bits 16 bits 16 bits
-
CS2
93CS40-95
20004-02-10
TMP93CS40/TMP93CS41
3.7
8-Bit Timers
The TMP93CS40 and S41 contain two 8-bit timers (Timers 0 and 1), each of which can be operated independently. The cascade connection also allows these timers to be used together as a 16-bit timer. The following four operating modes are supported for the 8-bit timers: * * * * 8-bit interval timer mode (2 timers) 16-bit interval timer mode (1 timer) 8-bit programmable square wave pulse generation (PPG: Variable duty with variable cycle) output mode (1 timer) 8-bit pulse width modulation (PWM: Variable duty with constant cycle) output mode (1 timer)
Figure 3.7.1 shows the block diagram of the 8-bit timers (Timer 0 and timer 1). Each timer consists of an 8-bit up counter, 8-bit comparator, and 8-bit timer register. Besides, one timer flip-flop (TFF1) is provided for the pair consisting of timer 0 and timer 1. Among the input clock sources for the timers, the internal clocks of T1, T4, T16, and T256 are obtained from the 9-bit prescaler shown in Figure 3.7.2. The operation modes and timer flip-flops of the 8-bit timers are controlled by the three control registers TMOD, TFFCR, and TRUN.
93CS40-96
20004-02-10
TRUN
TRUN
Timer F/F Run Run Clear Clear control TFF1 TO1 (also used as P71)
Selector 2n - 1 Overflow T1 T16 T256 Selector TMOD
TI0 pin T1 T4 T16
8-bit up counter (UC0) 8-bit up counter (UC1)
TFFCR, TMOD
TMOD TMOD Match detect INTT0 TO0TRG (To serial channel) 8-bit timer register TREG1
Figure 3.7.1 Block Diagram of 8-Bit Timers (Timers 0 and 1)
93CS40-97
8-bit comparator (CP0) 8-bit comparator (CP1) Select 8-bit timer register TREG0 Register buffer TFFCR Internal data bus
Match detection
Selector
TMOD
PPGTRG PWMTRG TREG0-WR
INTT1
TMP93CS40/TMP93CS41
20004-02-10
TMP93CS40/TMP93CS41
1. Prescaler There are 9-bit prescaler and prescaler clock selection registers to generate input clock signals for the 8-bit timers 0 and 1, the 16-bit timers 4 and 5, and the serial interfaces 0 and 1. Figure 3.7.2 shows the corresponding block diagram, and Table 3.7.1 shows prescaler clock signal resolution into 8 and 16-bit timers.
To CPU System clock (fSYS) To 5-bit prescaler 9-bit prescaler
2 fFPH
Selector
2 4 8 16 32 64 128 256 512 2 4
T1 T4 T16 T256 T1 T4 T16
To 8-bit timers 0 and 1
SYSCR0
Selector
XT1
fs
Run/stop and clear TRUN
To 16-bit timers 4 and 5
SYSCR1 2
1 T0 T2 T8 T32
Selector
To serial interfaces 0 and 1
fc
fc/2 fc/4 fc/8 fc/16
SYSCR1 X1
/2 /4 /8 /16
Figure 3.7.2 Block Diagram of the Prescaler Table 3.7.1 Prescaler Clock Resolution to 8 and 16-Bit Timers
at fc = 20 MHz, fs = 32.768 kHz Select System Clock 1 (fs) 00 0 (fc) (fFPH) Select Prescaler Clock Gear Value fs/23 fc/2 fc/2 fc/2 fc/2 fc/2
3 4 5 6 7
Prescaler Clock Resolution
T1
(244 s) (0.4 s) (0.8 s) (1.6 s) (3.2 s) (6.4 s) (244 s) (6.4 s) fs/25 fc/2 fc/2 fc/2 fc/2 fc/2
5 6 7 8 9
T4
(977 s) (1.6 s) (3.2 s) (6.4 s) (12.8 s) (25.6 s) (977 s) (25.6 s) 16-bit timer 8-bit timer fs/27 fc/2 fc/2 fc/2 fc/2 fc/2
7 8 9 10 11
T16
(3.9 ms) (6.4 s) (12.8 s) (25.6 s) (51.2 s) (102.4 s) (3.9 ms)
T256
fs/211 (62.5 ms) fc/211 (102.4 s) fc/212 (204.8 s) fc/213 (409.6 s) fc/214 (0.82 ms) fc/215 (1.64 ms) fs/211 (62.5 ms) fc/215 (1.64 ms)
XXX 000 (fc) 001 (fc/2) 010 (fc/4) 011(fc/8) 100 (fc/16) 01
(Low-frequency clock)
XXX XXX XXX: Don't care
XXX XXX
fs/23 fc/27
fs/25 fc/29
fs/27
10 (Note) (fc/16 clock)
fc/211 (102.4 s)
Note: The fc/16 clock cannot be used as a prescaler clock when the fs is used as a system clock.
93CS40-98
20004-02-10
TMP93CS40/TMP93CS41
The timer clock selected among fFPH, fc/16, and fs is divided by 4 and input to this prescaler. The selection is made by system clock control register SYSCR0. Resetting sets to 00, which selects the fFPH clock input to be divided by 4. The 8-bit timers 0 and 1 select among 4 clock inputs: T1, T4, T16, and T256 of the prescaler output. This prescaler can be run or stopped by the timer control register TRUN. Counting starts when is set to "1". The prescaler is cleared to zero and stops operation when is set to "0". Resetting clears to "0" and stops the prescaler. When the IDLE1 mode (in which only the oscillator operates) is used, set TRUN to "0" to reduce the power consumption of the prescaler before the "HALT" instruction is executed. 2. Up counter This is an 8-bit binary counter which counts up by the input clock pulse specified by TMOD. The input clock of timer 0 is selected from among the external clock from the TI0 pin, and the three internal clocks T1, T4, and T16, according to the value set in the TMOD register. The input clock used by timer 1 depends on the operation mode. When 16-bit timer mode is set, the overflow output of timer 0 is used as the input clock. When any mode other than 16-bit timer mode is set, the input clock is selected from among the internal clocks T1, T16, and T256 as well as the comparator output (Match detection signal) of timer 0 according to the set value of the TMOD register. Example: When TMOD = 01, the overflow output of timer 0 becomes the input clock of timer 1 (16-bit timer mode). When TMOD = 00 and TMOD = 01, T1 becomes the input of timer 1 (8-bit timer mode). Similarly, operation mode is also set by the TMOD register. When reset, it is initialized to TMOD = 00 whereby the up counter is placed in the 8-bit timer mode. The counting and stop and clear of the up counter can be controlled for each interval timer by the timer operation control register TRUN. When reset, all up counters will be cleared to stop the timers.
93CS40-99
20004-02-10
TMP93CS40/TMP93CS41
3. Timer registers These are 8-bit registers for setting a time interval. When the values of the timer registers match the values of the corresponding up counters, the comparator match detect signal becomes active. If the set value is 00H, this signal becomes active when the up counter overflows. Timer register TREG0 has a double buffer. The timer flip-flop control register TFFCR bit controls whether the double buffer structure should be enabled or disabled. It is disabled when = "0" and enabled when it is set to "1". In the double buffer enable state, the data set in the register buffer are transferred to the timer register when the 2n - 1 overflow occurs in PWM mode, or at the PPG cycle in PPG mode. Therefore, during timer mode, the double buffer cannot be used. Upon resetting, TFFCR will be initialized to = "0", disabling the double buffer. To use the double buffer, write data in the timer register, set to "1", and write the following data in the register buffer.
Up counter
Comparator (CP0)
Timer register 0 (TREG0) Matching detection of PPG cycle 2n - 1 overflow of PWM TREG0 WR
Shift trigger Register buffer 0 Write Internal data bus
Selector
TFFCR
Figure 3.7.3 Configuration of Timer Register 0 Note: The timer register and the register buffer are allocated at the same memory address. When = 0, the same value is written in the register buffer and in the timer register, while when = 1 the value is written only into the register buffer.
The memory address of each timer register is as follows. TREG0: 000022H TREG1: 000023H Both of these registers are write-only and cannot be read.
93CS40-100
20004-02-10
TMP93CS40/TMP93CS41
4. Comparator A comparator compares the value in the up counter with the values to which the timer register is set. When they match, the up counter is cleared to zero and an interrupt signal (INTT0 and INTT1) is generated. If the timer flip-flop inversion is enabled, the timer flip-flop is inverted at the same time. 5. Timer flip-flop The timer flip-flop (TFF1) is a flip-flop inverted by the match detect signal (8-bit comparator output). Inverting is enabled or disabled by the timer flip-flop control register TFFCR. After a reset operation, the value of TFF1 is undefined. Writing "01" or "10" to TFFCR sets "0" or "1" to TFF1. Additionally, writing 00 to this bit inverts the value of TFF1. (Software inversion.) The value in TFF1 can be output to the TO1 pin (also used as P71). When using the TFF1 contents as the timer output, the timer flip-flop should be set by the port 7 function register P7FC beforehand.
93CS40-101
20004-02-10
TMP93CS40/TMP93CS41
7
TRUN (0020H) Bit symbol Read/Write After reset Function PRRUN R/W 0
6
5
T5RUN 0
4
T4RUN 0
3
P1RUN R/W 0
2
P0RUN 0
1
T1RUN 0
0
T0RUN 0
Prescaler and timer run/stop control 0: Stop and clear 1: Run (Count up)
Count operation 0 1 Stop and clear Count
PRRUN: Operation of prescaler T5RUN: Operation of 16-bit timer (Timer 5) T4RUN: Operation of 16-bit timer (Timer 4) P1RUN: Operation of PWM timer (PWM1/timer 3) P0RUN: Operation of PWM timer (PWM0/timer 2) Note: TRUN is read as "1". T1RUN: Operation of 8-bit timer (Timer 1) T0RUN: Operation of 8-bit timer (Timer 0)
7
SYSCR0 Bit symbol (006EH) Read/Write After reset Function
Highfrequency oscillator (fc) 0: Stop
6
XTEN 0
Lowfrequency oscillator (fs) 0: Stop High-
5
RXEN 1
Lowfrequency
4
RXTEN 0
Clock frequency
3
RSYSCK R/W 0
selection timer
2
WUEF 0
Warm-up
1
PRCK1 0
00: fFPH 01: fs
0
PRCK0 0
XEN 1
Select prescaler clock
oscillator (fc) oscillator (fs) after release (Write) after release of
after release of the STOP 0: Don't care 10: fc/16 of the STOP mode mode 0: Stop 1: Oscillation 0: fc 1: fs 1: Start timer 11: (Reserved) (Read) 0: End warm up 1: Continue warm up
1: Oscillation 1: Oscillation the STOP mode 0: Stop 1: Oscillation
Select prescaler clock setting 00 fFPH 01 fs 10 fc/16 11 (Reserved)
Clock divided by 4
Figure 3.7.4 Timer Operation Control Register/System Clock Control Register
93CS40-102
20004-02-10
TMP93CS40/TMP93CS41
7
TMOD (0024H) Bit symbol Read/Write After reset Prohibit readmodifywrite Function 0 Operation mode 00: 8-bit timer 01: 16-bit timer 10: 8-bit PPG 11: 8-bit PWM T10M1
6
T10M0 0
5
PWMM1 0 PWM cycle 00: - 01: 26 - 1 10: 27 - 1 11: 28 - 1
4
PWMM0 W 0
3
T1CLK1 0 00: TO0TRG 01: T1 10: T16 11: T256
2
T1CLK0 0
1
T0CLK1 0 00: TI0 pin input 01: T1 10: T4 11: T16
0
T0CLK0 0
Source clock of timer 1
Source clock of timer 0
Input clock signal of timer 0 00 01 10 11 External input (TI0 pin input)
T1 (Prescaler) T4 (Prescaler) T16 (Prescaler)
Input clock of timer 1
TMOD 01 TMOD = 01
00 01 10 11
Comparator output of timer 0 Internal clock T1 Internal clock T16 Internal clock T256
Overflow output of timer 0 (16-bit timer mode)
Select PWM cycle 00 01 10 11
-
26 - 1 27 - 1 28 - 1
Set the operation modes of timers 0 and 1. 00 01 10 11 Two 8-bit timers (Timer 0 and timer 1) 16-bit timer 8-bit PPG output 8-bit PWM output (Timer 0) 8-bit timer (Timer 1)
Figure 3.7.5 Timer Mode Control Register (TMOD)
93CS40-103
20004-02-10
TMP93CS40/TMP93CS41
7
TFFCR (0025H) Bit symbol Read/Write After reset Function
6
5
4
DBEN R/W 0 Double buffer 0: Disable 1: Enable
3
TFF1C1 W 1 00: Invert TFF1 01: Set TFF1 10: Clear TFF1 11: Don't care
2
TFF1C0 1
1
TFF1IE R/W 0 TFF1 inversion trigger 0: Disable 1: Enable
0
TFF1IS 0 TFF1 inversion source 0: Timer 0 1: Timer 1
Select inverse signal of timer F/F1 ("Don't care" except in 8-bit timer mode)
TMOD
00

01 16-bit timer Inversion by match signal
10 PPG mode Inversion by matching signals of both timer 0 and timer 1
11 PWM mode Inversion by matching and overflow signals of timer 0
Inversion by 0 signal Inversion by 1 timer 1 match signal Inversion of timer flip-flop 1 (TFF1) 0 1 Disable inversion Enable inversion
timer 0 match mode
Control of timer flip-flop 1 (TFF1) Invert the value of TFF1 00 (Software inversion) 01 10 11 Set TFF1 to "1". Clear TFF1 to "0". Don't care
Double buffer control of TREG0 0 1 Note: TFFCR, are read as "1". Disable double buffer Enable double buffer
Figure 3.7.6 Timer Flip-Flop Control Register (TFFCR)
93CS40-104
20004-02-10
TMP93CS40/TMP93CS41
The operation of 8-bit timers will be described below: (1) 8-bit timer mode Two interval timers, designated "0" and "1", can be used independently as 8-bit interval timers. All interval timers operate in the same manner, and thus only the operation of timer 1 will be explained below. 1. Generating interrupts in a fixed cycle To generate timer 1 interrupts at constant intervals using timer 1 (INTT1), first stop timer 1. Set the operation mode and input clock speed by setting TMOD, and the cycle time by setting TREG1. Then, enable interrupt INTT1 and start the counting of timer 1. Example: To generate timer 1 interrupt every 1 second at fs = 32 kHz, set each register in the following manner. Clock condition System clock: Low frequency (fs) Prescaler clock: Low frequency (fs)
MSB 7 TRUN TMOD TREG1 INTET10 TRUN 6 X 0 1 1 X 5 4 3 2 1 0 LSB 0
- 0 1 1 1
- X
1 0
- X
1 1
- 1
1
- 0
0
-
1
- -
0
Stop timer 1, and clear it to "0". Set the 8-bit timer mode, and select T16 (4 ms at fs = 32 kHz) as the input clock. Set the timer register 1, 1 s / T16 = 250 = FAH (H signifies hexadecimal). Enable INTT1, and set it to "Level 5". Start timer 1 counting.
-
-
- -
- -
- 1
- -
X: Don't care, -: No change Use Table 3.7.1 for selecting the input clock. Note: The input clock choices available for timer 0 and timer 1 differ from each other as follows.
Timer 0: TI0 input, T1, T4, T16 Timer 1: Match detect signal of timer 0, T1, T16, T256
93CS40-105
20004-02-10
TMP93CS40/TMP93CS41
2. Generating a 50% duty, square-wave pulse The timer flip-flop (TFF1) is inverted at constant intervals, and its status is output to timer output pin (TO1). Example: To output a 2.4 s square wave pulse from the TO1 pin at fc = 20 MHz, set each register by the following procedures. Either timer 0 or timer 1 may be used, but this example uses timer 1. * Clock condition System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: fFPH
7 - 0 6 X 0 0 - X X X 5 - X 0 - X X - 4 - X 0 - X X - 3 - 0 0 1 2 - 1 0 0 1 0 - 1 1 1 1 1 0 - - 1 1
TRUN TMOD TREG1 TFFCR P7CR P7FC TRUN
Stop timer 1, and clear it to "0". Set the 8-bit timer mode, and select T1 (0.4 s at fc = 20 MHz) as the input clock cycle time. Set the timer register at 2.4 s / T1 / 2 = 3. Clear TFF1 to "0", and set to invert by the match detect signal from timer 1.
0 - X X 1
- - -
- - -
-
X -
Select P71 as TO1 pin. Start timer 1 counting.
X: Don't care, -: No change
T1
TRUN Bits 7 to 2 Up counter Bit1 Bit0 Comparator timing Comparator output (Matching detect) INTT1 Up counter clear 0 1 2 3 0 1 2 3 0 1 2 3 0
TFF1
TO1 1.2 s at fc = 20 MHz
Figure 3.7.7 Square Wave (50% duty) Output Timing Chart
93CS40-106
20004-02-10
TMP93CS40/TMP93CS41
3. Making timer 1 count up by matching the signal from the timer 0 comparator Set the 8-bit timer mode, and set the comparator output of timer 0 as the input clock to timer 1.
Comparator output (Timer 0 match) Timer 0 up counter (when TREG0 = 5) Timer 1 up counter (when TREG1 = 2) Timer 1 matching output 1 2 3 1 4 5 1 2 3 2 4 5 1 2 1 3
Figure 3.7.8 Timer 1 Count Up Regulated by Timer 0 (2) 16-bit timer mode A 16-bit interval timer is configured by using timer 0 and timer 1 as a pair. Setting timer mode register TMOD to "01" establishes a 16-bit timer mode. When set in 16-bit timer mode, the overflow output of timer 0 will become the input clock of timer 1, regardless of the set value of TMOD. Table 3.7.1 shows the selection of timer 0 input clock. The lower 8 bits of the timer (interrupt) cycle are set by the timer register TREG0, and the upper 8 bits are set by TREG1. Note that TREG0 always must be set first. (Writing data into TREG0 disables the comparator temporarily, and the comparator is restarted by writing data into TREG1.) Setting example: To generate an interrupt INTT1 every 0.4 seconds at fc = 20 MHz, set the following values for timer registers TREG0 and TREG1. Clock condition System clock: Clock gear: Prescaler clock:
High frequency (fc) 1 (fc) fFPH
When counting with the T16 input clock (6.4 s at 20 MHz) 0.4 s / 6.4 s = 62500 = F424H Therefore, set TREG1 = F4H and TREG0 = 24H, respectively.
93CS40-107
20004-02-10
TMP93CS40/TMP93CS41
The comparator signal is output from timer 0 each time the up counter UC0 matches TREG0, when the up counter UC0 is not to be cleared. With the timer 1 comparator, the match detect signal is output at each comparator check when the up counter UC1 and TREG1 values are found to match. When the match detect signal is output simultaneously from the comparators of both timer 0 and timer 1, the up counters UC0 and UC1 are cleared to 0, and the interrupt INTT1 is generated. If inversion is enabled, the value of the timer flip-flop TFF1 is inverted. Example: When TREG1 = 04H and TREG0 = 80H
0000H 0080H 0180H 0280H 0380H 0480H
Value of up counter (UC1, UC0) Timer 0 comparator match detect signal
Interrupt INTT1 Timer output TO1 Inversion
Figure 3.7.9 Timer Output by 16-Bit Timer Mode (3) 8-bit PPG (Programmable pulse generation) output mode Square wave pulse can be generated at any frequency and duty by timer 0. The output pulse may be either low-active or high-active. In this mode, timer 1 cannot be used. Timer 0 outputs a pulse to the TO1 pin (also used as P71).
tH tL
t
TREG0 and UC0 match (Interrupt INTT0) TREG1 and UC0 match (Interrupt INTT1) TO1 TREG0 TREG1
Figure 3.7.10 8-Bit PPG Output Waveforms
93CS40-108
20004-02-10
TMP93CS40/TMP93CS41
In this mode, a programmable square wave is generated by inverting the timer output each time the 8-bit up counter (UC0) matches the timer registers TREG0 and TREG1. However, it is necessary for the set value of TREG0 to be smaller than that of TREG1. Though the up counter (UC1) of timer 1 is not used in this mode, UC1 should be set for counting by setting TRUN to "1". Figure 3.7.11 shows the block diagram for this mode.
TO1 TI0 pin T1 T4 T16 TRUN Selector 8-bit up counter (UC0) TFF1 TFFCR
Inversion TMOD INTT0 Comparator
Comparator
INTT1
TREG0 TREG0-WR Selector Shift trigger Register buffer TFFCR Internal data bus TREG1
Figure 3.7.11 Block Diagram of 8-Bit PPG Output Mode When the double buffer of TREG0 is enabled in this mode, the value of the register buffer will be shifted in TREG0 each time TREG1 matches UC0. Use of the double buffer makes the handling of low duty waves easy (when duty is varied).
Match with TREG0 and up counter 0 (Up counter = Q1) Match with TREG1 TREG0 (Value to be compared) Register buffer Shift from register buffer Q1 Q2 Q2 Q3 TREG 0 (Register buffer) write (Up counter = Q2)
Figure 3.7.12 Operation of Register Buffer
93CS40-109
20004-02-10
TMP93CS40/TMP93CS41
Example: Generating 1/4 duty 62.5 kHz pulse (at fc = 20 MHz)
16 s
Clock condition System clock: Clock gear: Prescaler clock: *
High frequency (fc) 1 (fc) fFPH
Calculate the value to be set in the timer register. To obtain a frequency of 62.5 kHz, the pulse cycle time t should be: t = 1/62.5 kHz = 16 s. Given T1 = 0.4 s (at 20 MHz), 16 s / 0.4 s = 40 Consequently, set the timer register 1 (TREG1) to TREG1 = 40 = 28H and then to obtain a duty of 1/4, t x 1/4 = 16 s x 1/4 = 4 s 4 s / 0.4 s = 10 Therefore, set timer register 0 (TREG0) to TREG0 = 10 = 0AH.
7 - 1 0 0 - 6 X 0 0 0 - 5 - X 0 1 - 4 - X 0 0 X 3 - X 1 1 0 2 - X 0 0 1 1 0 0 1 0 1 0 0 1 0 0 X Stop timers 0 and 1, and clear then. Set the 8-bit PPG mode, and select T1 as input clock. Write "0AH". Write "28H". Set TFF1 and enable the inversion. Writing "10" provides negative logic pulse. P7CR P7FC TRUN
TRUN TMOD TREG0 TREG1 TFFCR

X X 1
X X X
X X -
X X -
- - -
- - -
1 1 1
-
X 1
Set P71 as the TO1 pin. Start timer 0 and timer 1 counting.
X: Don't care, -: No change
93CS40-110
20004-02-10
TMP93CS40/TMP93CS41
(4) 8-bit PWM output mode This mode is valid only for timer 0. In this mode, the maximum 8-bit resolution of the PWM pulse can be output. The PWM pulse is output to the TO1 pin (also used as P71) when using timer 0. Timer 1 can also be used as an 8-bit timer. Timer output is inverted when the up counter (UC0) matches the set value of timer register TREG0, or when 2n - 1 (n = 6, 7, or 8; specified by TMOD) counter overflow occurs. Up counter UC0 is cleared when 2n - 1 counter overflow occurs. To use this PWM mode, the following conditions must be satisfied. (Set value of timer register) < (Set value of 2n - 1 counter overflow) (Set value of timer register) 0
TREG0 and UC0 match 2n - 1 overflow (Interrupt INTT0) TO1
tPWM (PWM cycle)
Figure 3.7.13 8-Bit PWM Waveforms Figure 3.7.14 shows the block diagram of operations in this mode.
TRUN TI0 T1 T4 T16 8-bit up counter (UC 0) TO1 TFFCR
Selector
Clear TMOD = 11 TMOD
TFF1
TMOD
2n - 1 overflow control Overflow Comparator
Inversion
INTT 0 TREG0 Selector TREG0-WR Register buffer TFFCR Internal data bus Shift trigger
Figure 3.7.14 Block Diagram of Operations in 8-Bit PWM Mode
93CS40-111
20004-02-10
TMP93CS40/TMP93CS41
In this mode, the value of the register buffer will be shifted into TREG0 if a 2n - 1 overflow is detected while the double buffer of TREG0 is enabled. Use of the double buffer makes easy the handling of small-duty waves.
Match with TREG0 Up counter = Q1 2n - 1 overflow TREG 0 (Value to be compared) Register buffer Shift into TREG0 Q1 Q2 Q2 Q3 TREG0 (Register buffer) write Up counter = Q2
Figure 3.7.15 Operation of Register Buffer Example: To output the following PWM waves to the TO1 pin at fc = 20 MHz.
28.8 s 50.8 s
Clock conditions System clock: Clock gear: Prescaler clock:
High frequency (fc) 1 (fc) fFPH
To implement a PWM cycle of 50.8 s by utilizing T1 = 0.4 s (at fc = 20 MHz), 50.8 s / 0.4 s = 127 = 2n - 1 Consequently, n should be set to 7. As the period of low level is 28.8 s, for T1 = 0.4 s, set the following value for TREG0. 28.8 s / 0.4 s = 72 = 48H
MSB 7 TRUN TMOD TREG0 TFFCR P7CR P7FC TRUN 6 X 1 1 X X X X 5 4 3 2 1 LSB 0 0 1 0 X - X 1 Stop timer 0 and clear it. Set 8-bit PWM mode (cycle: 27 - 1) and select T1 as the input clock. Writes "48H". Clear TFF1, enable the inversion and double buffer. Set P71 as the TO1 pin. Start timer 0 counting.
- 1
0 X X X 1
- 1
0 X X X
- 0
0 X X X
- -
1 1 - - -
- -
0 0 - - -
- 0
0 1 1 1
-
-
-
X: Don't care, -: No change
93CS40-112
20004-02-10
TMP93CS40/TMP93CS41
Table 3.7.2 PWM Cycle
at fc = 20 MHz, fs = 32.768 kHz Select System Clock 1 (fs) 00 0 (fc) (fFPH) Select Prescaler Clock XXX 000 (fc) 001 (fc/2) 010 (fc/4) 011 (fc/8) 100 (fc/16) 01 XXX (Low-frequency clock) XXX 10 (fc/16 clock) XXX
403.2 s 1.61 ms 6.45 ms 812.8 s 3.25 ms 13.04 ms 1.63 ms 6.53 ms 26.11 ms
PWM Cycle
Gear Value
2 -1
6
7 2 -1
8 2 -1
T1
15.4 ms 25.2 s 50.4 s 100.8 s 201.6 s 403.2 s
T4
61.5 ms 100.8 s 201.6 s 403.2 s 806.4 s 1.61 ms
T16
246 ms 403.2 s 806.4 s 1.61 ms 3.23 ms 6.45 ms
T1
31.0 ms 50.8 s 101.6 s 203.2 s 406.4 s 812.8 s
T4
124 ms 203.2 s 406.4 s 812.8 s 1.63 ms 3.25 ms
T16
496 ms 812.8 s 1.63 ms 3.26 ms 6.52 ms
T1
62.3 ms 102.0 s 204.0 s 408.0 s 816.0 s
T4
249 ms 408.0 s 816.0 s 1.63 ms 3.26 ms 6.53 ms
T16
996 ms 1.63 ms 3.26 ms 6.53 ms 13.06 ms 26.11 ms
13.04 ms 1.63 ms
XXX
15.4 ms
61.5 ms
246 ms
31.0 ms
124 ms
496 ms
62.3 ms
249 ms
996 ms
XXX: Don't care (5) The list of 8-bit timer modes Table 3.7.3 shows the list of 8-bit timer modes. Table 3.7.3 Timer Mode Setting Registers Register Name Bit Name Function T10M Timer Mode PWMM PWM Cycle TMOD T1CLK Upper Timer Input Clock
-
TFFCR T0CLK Lower Timer Input Clock
External clock, T1, T4, T16 (00, 01, 10, 11)
TFF1IS Timer F/F Invert Signal Select
-
0: Lower timer output 1: Upper timer output
16-bit timer mode
01
-
8-bit timer x 2 channels
00
-
Lower timer match: T1, 16, 256 (00, 01, 10, 11)
External clock,
T1, T4, T16 (00, 01, 10, 11)
External clock, T1, T4, T16 (00, 01, 10, 11) External clock, T1, T4, T16 (00, 01, 10, 11)
8-bit PPG x 1 channel
10
-
-
-
8-bit PWM x 1 channel
11
26 - 1, 27 - 1, 28 - 1 (01, 10, 11)
- T1, T16, T256 (01, 10, 11)
-
8-bit timer x 1 channel
11
-
-
Output disabled
-: Don't care
93CS40-113
20004-02-10
TMP93CS40/TMP93CS41
3.8
8-Bit PWM Timers
The TMP93CS40 and TMP93CS41 have two built-in 8-bit PWM timers (Timers 2 and 3). Each of these timers has two operating modes. * * 8-bit PWM output mode 8-bit interval timer mode
Figure 3.8.1, Figure 3.8.2 are block diagram of 8-bit PWM timers 0 and 1 (Timers 2 and 3). PWM timers consist of an 8-bit up counter, 8-bit comparator, and 8-bit timer register. Two timer flip-flops (TFF2 for timer 2 and TFF3 for timer 3) are provided. Input clocks P1, P4, and P16 for the PWM timers can be obtained using the 5-bit built-in prescaler (PWM dedicated prescaler). PWM timer operating mode and timer flip-flops are controlled by four control registers (P0MOD, P1MOD, PFFCR, and TRUN). PWM timers 0 and 1 can be used independently. All PWM timers operate in the same manner, and thus only the operation of PWM timer 0 will be explained below.
93CS40-114
2004-02-10
TMP93CS40/TMP93CS41
P0MOD TRUN Selector
Flip-flop 2 (TFF2) Set Clear
PWM2-OUT (TO2)
Flip-flop control
P1 P4 P16
Run Clock control 8-bit up counter (UC2)
Clear
PFFCR PFFCR
2n - 1 P0MOD
Overflow
8-bit comparator (CP2)
P0MOD Match detect
Interrupt control
INTT2
P0MOD 8-bit timer register TREG2 Shift trigger B Selector Register buffer Register write P0MOD Internal data bus S A TREG-WR
Figure 3.8.1 Block Diagram of 8-Bit PWM Timer 0 (Timer 2)
93CS40-115
2004-02-10
TMP93CS40/TMP93CS41
P1MOD TRUN Selector
Flip-flop 3 (TFF3) Set Clear
PWM3-OUT (TO3)
Flip-flop control PFFCR PFFCR
P1 P4 P16 Clock control
Run 8-bit up counter (UC3)
Clear
2n - 1 P1MOD
Overflow
8-bit comparator (CP3)
P1MOD Match detect
Interrupt control
INTT3
P1MOD 8-bit timer register TREG3 Shift trigger B Selector Register buffer Register write P1MOD Internal data bus S A TREG-WR
Figure 3.8.2 Block Diagram of 8-Bit PWM Timer 1 (Timer 3)
93CS40-116
2004-02-10
TMP93CS40/TMP93CS41
1. Prescaler There are 5-bit prescaler and prescaler clock selection registers to generate clock inputs for 8-bit PWM timers 0 and 1. Figure 3.8.3 shows the block diagram. Table 3.8.1 shows prescaler clock resolution into 8-bit PWM timers 0 and 1.
To CPU
2
fFPH
2
5-bit prescaler
4 8 16 32
Selector
2
4
P16 P4 P1
To 8-bit PWM timers 0 and 1
XT1
fs
Selector
SYSCR0 Run/stop & clear TRUN
To 9-bit prescaler for 8-bit timers 0 and 1, 16-bit timers/event counters 4 and 5, and serial interfaces 0 and 1.
Selector
SYSCR1
fc
fc/2 fc/4 fc/8 fc/16
SYSCR1 X1 /2 /4 /8 /16
Figure 3.8.3 Block Diagram of the Prescaler
Table 3.8.1 Prescaler Clock Resolution to 8-Bit PWM Timers 0 and 1
at fc = 20 MHz, fs = 32.768 kHz
Select System Select Prescaler Clock Clock
1 (fs) 00 (fFPH)
Gear Value
XXX 000 (fc) 001 (fc/2) 010 (fc/4) 011 (fc/8) 100 (fc/16)
Prescaler Clock Resolution P1
fs/22 (122 s) fc/2 (0.2 s)
2 3 4 5 6 4 5 6 7 8
P4
fs/24 (488 s) fc/2 (0.8 s) fc/2 (1.6 s) fc/2 (3.2 s) fc/2 (6.4 s) fc/2 (12.8 s) fs/24 (488 s)
P16
fs/26 (1.95 ms) fc/26 (3.2 s) fc/27 (6.4 s) fc/28 (12.8 s) fc/29 (25.6 s) fc/210 (51.2 s) fs/26 (1.95 ms)
fc/2 (0.4 s) fc/2 (0.8 s) fc/2 (1.6 s) fc/2 (3.2 s) fs/22 (122 s)
0 (fc)
XXX
01 (Low-frequency clock) 10 (fc/16 clock)
XXX
XXX
XXX
fc/26 (3.2 s)
fc/28 (12.8 s)
fc/210 (51.2 s)
XXX: Don't care Note: The fc/16 clock cannot be used as a prescaler clock when the fs is used as a system clock.
93CS40-117
2004-02-10
TMP93CS40/TMP93CS41
The clock selected among fFPH, fc/16, and fs is divided by 2 and input to this prescaler. The selection is made by the system clock control register SYSCR0. Resetting sets to 00, selecting the fFPH clock input to be divided by 2. The TRUN register which controls this prescaler, is also used for the other timers. So, this prescaler cannot be operated independently. The 8-bit PWM timers 0 and 1 select one of the clock inputs: P1, P4, and P16, from among the three prescaler outputs. This prescaler also can be run or stopped by TRUN as described in discussion of the 8-bit timer. Counting starts when is set to 1. The prescaler is cleared and stops operation when is set to 0. Resetting clears and stops the prescaler. When the IDLE1 mode (with only the oscillator operating) is used, set TRUN to "0" to reduce the power consumption of the prescaler before the "HALT" instruction is executed. 2. Up counter The up counter is an 8-bit binary counter which counts up using the input clock specified by PWM0 mode register P0MOD. The input clock for the up counter is selected from among the internal clocks P1, P4, and P16 (PWM dedicated prescaler output) depending on the value in . Operating mode is set by P0MOD. At reset, is initialized to "0", and thus the up counter is placed in PWM mode. In PWM mode, the up counter is cleared when a 2n - 1 overflow occurs; in timer mode, the up counter is cleared at compare and match. Count/stop and clear of the up counter can be controlled for each PWM timer using the timer operation control register TRUN. Resetting clears all up counters and stops all PWM timers. 3. Timer register The 8-bit register is used for setting a time interval. When the value set in the timer register (TREG2) matches the value in the up counter, the match detect signal of the comparator becomes active. Timer register TREG2 is paired with a register buffer to make a double buffer structure. TREG2 controls double buffer enable/disable by P0MOD. The double buffer is disabled when = 0, and enabled when = 1. In double buffer enable state, data are transferred from register buffer to timer register when a 2n - 1 overflow occurs in PWM mode, or when compare and match occur in 8-bit timer mode. A PWM timer can be operated in timer mode in double buffer enable state, whereas timers 0 and 1 cannot. At reset, is initialized to 0 to disable the double buffer. The same value is set in both the register buffer and the timer register. To use the double buffer, write the data in the timer register first, then set to 1 and write the following data in the register buffer.
93CS40-118
2004-02-10
TMP93CS40/TMP93CS41
Up counter
Comparator
Timer register (TREG2) Shift trigger Register buffer Write Internal data bus Selector 8-bit match detect PWM2n - 1 overflow TREG2 WR
Figure 3.8.4 Structure of Timer Registers 2 Memory addresses of the timer registers are as follows: TREG2: 000026H (PWM timer 0) TREG3: 000027H (PWM timer 1) The timer register and register buffer are allocated to the same memory address. When = 0, the same value is written to both the register buffer and timer register. When = 1, a value is written to the register buffer only. Register buffer values can be read when reading the above addresses. The timer register is write-only and it cannot be read. 4. Comparator This element compares the value in the up counter with the value in the timer register (TREG2). When they match, the comparator outputs the match detect signal. A timer interrupt (INTT2) is generated at compare and match if the interrupt select bit of the mode register (P0MOD) is set to 1. In timer mode, the comparator clears the up counter at compare and match. It also inverts the value of the timer flip-flop if timer flip-flop invert is enabled. 5. Timer flip-flop The value of the timer flip-flop is inverted by the match detect signal (comparator output) of each interval timer or by 2n - 1 overflow. The flip-flop value can be output to the timer output pin TO2 (also used as P72).
93CS40-119
2004-02-10
TMP93CS40/TMP93CS41
7
P0MOD (0028H) Bit symbol Read/Write After reset Function FF2RD R - Flip-flop (Flip-flop 2) output data
6
DB2EN 0
5
PWM0INT 0
4
PWM0M 0
3
T2CLK1 W 0 00: P1 01: P4 10: P16 11: Don't care
2
T2CLK0 0
1
PWM0S1 0 00: 26 - 1 01: 27 - 1 10: 28 - 1 11: Don't care
0
PWM0S0 0
1: Double 0: 2n - 1 0: PWM buffer 2 mode overflow enable interrupt 1: Timer mode 1: Compare and match interrupt
Read-modify-write is prohibited.
Select PWM0 cycle 00 01 10 11 26 - 1 27 - 1 28 - 1 Don't care
Select PWM0 input clock 00 01 10 11 P1 P4 P16 Don't care
Select PWM0 mode 0 1 PWM mode 8-bit timer mode
Select PWM0 interrupt 0 1 Overflow interrupt Compare and match interrupt
Control double buffer 0 1 Disable Enable
PWM timer flip-flop 2 (TFF2) output value (TO2)
Figure 3.8.5 8-bit PWM0 Mode Control Register
93CS40-120
2004-02-10
TMP93CS40/TMP93CS41
7
P1MOD (0029H) Bit symbol Read/Write After reset Function FF3RD R - Flip-flop (Flip-flop 3) output data
6
DB3EN 0
5
PWM1INT 0
4
PWM1M 0
3
T3CLK1 W 0 00: P1 01: P4 10: P16 11: Don't care
2
T3CLK0 0
1
PWM1S1 0 00: 26 - 1 01: 27 - 1 10: 28 - 1 11: Don't care
0
PWM1S0 0
1: Double 0: 2n - 1 0: PWM buffer 3 mode overflow enable interrupt 1: Timer mode 1: Compare and match interrupt
Read-modify-write is prohibited.
Select PWM1 cycle 00 01 10 11 26 - 1 27 - 1 28 - 1 Don't care
Select PWM1 input clock 00 01 10 11 P1 P4 P16 Don't care
Select PWM1 mode 0 1 PWM mode 8-bit timer mode
Select PWM1 interrupt 0 1 Overflow interrupt Compare and match interrupt
Control double buffer 0 1 Disable Enable
PWM timer flip-flop 3 (TFF3) output value (TO3)
Figure 3.8.6 8-Bit PWM 1 Mode Control Register
93CS40-121
2004-02-10
TMP93CS40/TMP93CS41
7
PFFCR (002AH) Bit symbol Read/Write After reset Function 1
00: Don't care 01: Set TFF3 10: Clear TFF3 11: Don't care
6
FF3C0 W 1
5
FF3TRG1 0 R/W
4
FF3TRG0 0
3
FF2C1 W 1
00: Don't care 01: Set TFF2 10: Clear TFF2 11: Don't care
2
FF2C0 1
1
FF2TRG1 0 R/W
0
FF2TRG0 0
FF3C1
00: Disable TFF3 inverted. 01: Invert by match. 10: Set by match; clear by overflow 11: Clear by match; set by overflow.
00: Disable TFF2 inverted. 01: Invert by match. 10: Set by match; clear by overflow 11: Clear by match; set by overflow.
Select PWM timer flip-flop 2 (TFF2) trigger 00 01 10 11 Disable TFF2 trigger. Invert by compare and match. Set by compare and match. Clear by 2n - 1 overflow. Clear by compare and match. Set by 2n -1 overflow.
Control PWM timer flip-flop 2 (TFF2) 00 Don't care 01 10 11 Set TFF2 to "1". Clear TFF2 to "0". Don't care
Select PWM timer flip-flop 3 (TFF3) trigger 00 01 10 11 Disable TFF3 trigger. Invert by compare and match. Set by compare and match. Clear by 2 n - 1 overflow. Clear by compare and match. Set by 2 n - 1 overflow.
Control PWM timer flip-flop 3 (TFF3) 00 01 10 11 Don't care Set TFF3 to "1". Clear TFF3. Don't care
Figure 3.8.7 8-Bit PWM Flip-flop Control Register
93CS40-122
2004-02-10
TMP93CS40/TMP93CS41
7
TRUN (0020H) Bit symbol Read/Write After reset Function PRRUN R/W 0
6
5
T5RUN 0
4
T4RUN 0
3
P1RUN R/W 0
2
P0RUN 0
1
T1RUN 0
0
T0RUN 0
Prescaler and timer run/stop control 0: Stop and clear 1: Run (Count up)
Count operation 0 1 Stop and clear Count
Note: TRUN is read as "1".
PRRUN: Operation of prescaler T5RUN: Operation of 16-bit timer (Timer 5) T4RUN: Operation of 16-bit timer (Timer 4) P1RUN: Operation of PWM timer 1 P0RUN: Operation of PWM timer 0 T1RUN: Operation of 8-bit timer (Timer 1) T0RUN: Operation of 8-bit timer (Timer 0)
7
SYSCR0 Bit symbol (006EH) Read/Write After reset Function
Highfrequency oscillator (fc) 0: Stop 1: Oscillator operates
6
XTEN 0
Lowfrequency oscillator (fc) 0: Stop 1: Oscillator operates
5
RXEN 1
Highfrequency oscillator (fc) after release of Low-
4
RXTEN 0
frequency oscillator (fc) after release of
3
RSYSCK R/W 0
Select clock after release timer of STOP mode 0: fc
2
WUEF 0
Warm-up
1
PRCK1 0
00: fFPH 01: fs
0
PRCK0 0
XEN 1
Select prescaler clock
(Write)
0: Don't care 10: fc/16 1: Start timer 11: (Reserved) (Read) 0: End warm up 1: Continue warm up
STOP mode STOP mode 1: fs 0: Stop 1: Oscillator operates 0: Stop 1: Oscillator operates
Select gear value of high frequency 00 fFPH 01 fs 10 fc/16 11 (Reserved) Clock divided by 2
Figure 3.8.8 Timer Operation Control Register/System Clock Control Register
93CS40-123
2004-02-10
TMP93CS40/TMP93CS41
The following explains PWM timer operations. (1) PWM timer mode PWM output changes under the following two conditions. Condition 1: * * * * TFF2 is cleared when the value in the up counter (UC2) matches the value set in the TREG2. TFF2 is set to 1 when a 2n - 1 counter overflow (n = 6, 7, or 8) occurs. Condition 2: TFF2 is set to 1 when the value in the up counter (UC2) matches the value set in TREG2. TFF2 is cleared when a 2n - 1 counter overflow (n = 6, 7, or 8) occurs. The up counter (UC2) is cleared by a 2n - 1 counter overflow. The PWM timer can output 0% to 100% duty pulses because a 2n - 1 counter overflow has a higher priority. That is, to obtain 0% output (Always low), the mode used to set TFF2 to 0 due to overflow (PFFCR = 10) must be set and 2n - 1 (A value indicating an overflow) must be set in TREG2. To obtain 100% output (Always high), the mode must be changed by setting PFFCR = 11 and then TREG2 must be set to 2n - 1. PWM timing
2n - 1 PWM counter Timing in detail m-1 m m+1 2 -3
n
2 -2
n
0
01
Match detect 2n - 1 overflow counter clear Match detect
Overall timing (Note)
2 n - 1 overflow Timer flip-flop output (TO2/TO3)
Figure 3.8.9 Output Waves in PWM Timer Mode Note: The waves pictured above are obtained in the mode in which the flip-flop is set by a match with the timer register (TREG), and is reset by an overflow.
93CS40-124
2004-02-10
TMP93CS40/TMP93CS41
Figure 3.8.10 is a block diagram of this mode.
P1
P4 P16
Clock control
8-bit up counter (UC2)
Clear P0MOD 2n - 1 overflow control Overflow
P0MOD
8-bit comparator (CP2)
Match
PFFCR PFFCR Timer flip-flop control
TO2
B
8-bit timer register (TREG2) Shift trigger
Selector TREG2 WR
A S
Register buffer P0MOD Internal data bus
Interrupt control
INTT2
P0MOD
Figure 3.8.10 Block Diagram of PWM Timer Mode (PWM0) In this mode, enabling double buffer is very useful. The register buffer value shifts into TREG2 when a 2n - 1 overflow is detected, when double buffer is enabled. Use of the double buffer makes the handling of low duty waves easy.
Match with TREG2 2n - 1 overflow TREG 2 (Compared value) Register buffer (Up counter = Q1) (Up counter = Q2) Shift from register buffer Q1 Q2 Q2 Q3 Register buffer write
Figure 3.8.11 Register Buffer Operation
93CS40-125
2004-02-10
TMP93CS40/TMP93CS41
Example: To output the following PWM waves to the TO2 pin using PWM0 at fc = 20 MHz Clock condition System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: fFPH
12 s 25.4 s
To implement 25.4 s as the PWM cycle regulated by P1 = 0.2 s (at fc = 20 MHz) 2n - 1 = 25.4 s / 0.2 s = 127. Consequently, set n to 7. Since the low level cycle = 12 s; for P1 = 0.2 s 3CH = 12 s / 0.2 = 60 set the 3CH in TREG2.
7 - - 0 - - X X 1 6 X 0 0 1 - X X X 5 - 0 1 0 - X X - 4 - 0 1 0 - X X - 3 - 0 1 0 0 - - - 2 0 0 1 0 1 1 1 1 1 - 0 0 0 1 - - - 0 - 1 0 1 0 - X -
TRUN P0MOD TREG2 P0MOD PFFCR P7CR P7FC TRUN
Stops PWM0 and clears it. Sets PWM (27 - 1) mode, input clock P1, overflow interrupt, and disables double buffer. Writes 3CH. Enables double buffer. Sets TFF2 and the mode in which TFF2 is set by compare and match, and cleared by overflow. Sets P72 as TO2 pin. Starts PWM0 counting.
X: Don't care, -: No change
93CS40-126
2004-02-10
TMP93CS40/TMP93CS41
Table 3.8.2 PWM Cycle
at fc = 20 MHz, fs = 32.768 kHz Select System Clock 1 (fs) 00 0 (fc) (fFPH) Select Prescaler Clock
PWM cycle
Gear Value XXX 000 (fc) 001 (fc/2) 010 (fc/4) 011 (fc/8) 100 (fc/16)
2 -1
6
7 2 -1
8 2 -1
P1
7.69 ms 12.6 s 25.2 s 50.4 s 100.8 s 201.6 s 7.69 ms 201.6 s
P4
30.8 ms 50.4 s 100.8 s 201.6 s 403.2 s 806.4 s 30.8 ms 806.4 s
P16
123 ms 201.6 s 403.2 s 806.4 s 1.61 ms 3.23 ms 123 ms
P1
15.5 ms 25.4 s 50.8 s 101.6 s 203.2 s 406.4 s 15.5 ms 406.4 s
P4
62.0 ms 101.6 s 203.2 s 406.4 s 812.8 s 1.63 ms 62.0 ms
P16
248 ms 406.4 s 812.8 s 1.63 ms 3.25 ms 6.50 ms 248 ms
P1
31.1 ms 51.0 s 102.0 s 204.0 s 408.0 s 816.0 s 31.1 ms 816.0 s
P4
125 ms 204.0 s 408.0 s 816.0 s 1.63 ms 3.26 ms 125 ms
P16
498 ms 816.0 s 1.63 ms 3.26 ms 6.53 ms 13.06 ms 498 ms
XXX XXX
01 (Low frequency) 10 (fc/16 clock)
XXX XXX
3.23 ms
1.63 ms
6.50 ms
3.26 ms
13.06 ms
XXX: Don't care (2) 8-bit timer mode Both PWM timers can be used independently as 8-bit interval timers. Since both timers operate in exactly the same way, PWM0 (timer 2) is used for the purposes of explanation. 1. Generating interrupts at a fixed interval To generate timer 2 interrupt (INTT2) at a fixed interval using the PWM0 timer, first stop PWM0, then set the operating mode, input clock, and interval in the P0MOD and TREG2 registers. Next, enable INTT2 and start counting PWM0. Example: To generate a timer 2 interrupt every 32 s at fc = 20 MHz, set registers as follows: Clock condition System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: fFPH
7 - X 1 - 1 6 X 0 0 - X 5 - 1 1 - - 4 - 1 0 - - 3 - 0 0 1 - 2 0 0 0 1 1 1 - X 0 0 - 0 - X 0 0 -
TRUN P0MOD TREG2 INTEPW10 TRUN
Stops PWM timer 0 and clears it. Sets 8-bit timer mode and selects P1 (0.2 s) and compare interrupt. Sets A0H (= 32 s / 0.2 s) in the timer register. Enables INTT2 and sets interrupt level 4. Starts counting PWM0.
X: Don't care, -: No change Select an input clock using Table 3.8.1. Note: To generate interrupts in 8-bit timer mode, bit5 (Interrupt control bit of P0MOD) must be set to 1.
93CS40-127
2004-02-10
TMP93CS40/TMP93CS41
2. Generating a 50% square wave To generate a 50% square wave, invert the timer flip-flop at a fixed interval and output the timer flip-flop value to the timer output pin (TO2). Example: To output a 2.4 s square wave at fc = 20 MHz from the TO2 pin, set the registers as follows. Clock condition System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: fFPH
7 - X 0 - X X 1 6 X 0 0 - X X X 5 - 1 0 - X X - 4 - 1 0 - X X - 3 - 0 0 1 - - - 2 0 0 1 0 1 1 1 1 - X 1 0 - - - 0 - X 0 1 - X -
TRUN P0MOD TREG2 PFFCR P7CR P7FC TRUN
Stops PWM0 and clears it. Sets 8-bit timer mode and selects P1 (0.2 s) as the input clock. Sets 2.4 s / 0.2 s / 2 = 6 in the timer register. Clears TFF2 and inverts using comparator output. Sets P72 as the TO2 pin. Starts counting PWM0.
X: Don't care, -: No change
P1 TRUN Up counter Comparator timing Match detect UC clear TFF2 TO2 1.2 s (at fc = 20 MHz) 01 02 03 04 05 06 01 02 04 05 06 01 02
Figure 3.8.12 Square Wave (50% duty) Output Timing Chart
93CS40-128
2004-02-10
TMP93CS40/TMP93CS41
This mode is as shown in Figure 3.8.13 below.
P1 P4 P16 8-bit up counter Clock control (UC2) P0MOD Clear
8-bit comparator (CP2)
Match
Timer flip-flop control
TO2
B
8-bit timer register (TREG2) Selector Shift trigger
PFFCR PFFCR
Interrupt INTT2 Register buffer control
TREG2 WR
A
S
P0MOD P0MOD Register write Internal data bus
Figure 3.8.13 Block Diagram of 8-Bit Timer Mode
93CS40-129
2004-02-10
TMP93CS40/TMP93CS41
3.9
16-Bit Timers
The TMP93CS40 and TMP93CS41 contain two multifunctional 16-bit timer/event counters (Timer 4 and timer 5) which support the following operation modes. * * * * * * 16-bit interval timer mode 16-bit event counter mode 16-bit programmable pulse generation (PPG) mode Frequency measurement mode Pulse width measurement mode Time differential measurement mode
Each timer/event counter consists of a 16-bit up counter, two 16-bit timer registers (One with a double-buffer), two 16-bit capture registers, two comparators, a capture input controller, a timer flip-flop and the control circuit. Timer/event counters are controlled T4FFCR/T5FFCR, TRUN and T45CR. by 4 control registers: T4MOD/T5MOD,
Figure 3.9.1, Figure 3.9.2 show the block diagram of the 16-bit timer/event counters (Timer 4 and timer 5). Timers 4 and 5 can be used independently. All timers operate in the same manner except for the following points, and thus only the operation of timer 4 will be explained below. Points Differing between Timers 4 and 5 16-Bit Timer 4
Timer out pin Different phased pulse output mode TO4 pin (TFF4) TO5 pin (TFF5) Yes
16-Bit Timer 5
TO6 pin (TFF6) No (No TO7 pin)
93CS40-130
2004-02-10
Internal data bus Upper byte Upper byte Capture register 2 CAP2 Trigger Lower byte Capture register 1 CAP1
Trigger
Lower byte
T4MOD
Software capture
T4MOD T4FFCR
TFF1 TI4 TI5 TRUN Clear Selector 16-bit up counter UC4 TRUN T4MOD T4MOD T1 T4 T16
Capture control
Timer flip-flop control INTTR5 INTTR4 PG0 shift trigger
TFF4 TFF5
TO4 TO5 Does not exist in timer 5
T4MOD TI4
INT4 INT5
Figure 3.9.1 Block Diagram of 16-Bit Timer (Timer 4)
Comparator CP4 Match detection Comparator CP5 TREG4 Selector TREG4-WR Register buffer 4 Upper byte Internal data bus Lower byte TREG5 Upper byte T45CR Lower byte
93CS40-131
Match detection
TMP93CS40/TMP93CS41
2004-02-10
Internal data bus Upper byte Upper byte Capture register 4 CAP4 Trigger T5FFCR Lower byte Lower byte
T5MOD Software capture
Capture register 3 CAP3 Trigger
TFF1 TI6 TI7 TRUN Clear Selector 16-bit up counter UC5 TRUN T5MOD Match detection T5MOD T1 T4 T16
Capture control
Timer flip-flop control TFF6 INTTR7 INTTR6 PG0 shift trigger TO6
T5MOD TI6
INT6 INT7
Figure 3.9.2 Block Diagram of 16-Bit Timer (Timer 5)
93CS40-132
Comparator CP6 TREG6 Selector TREG6-WR Register buffer 6 Upper byte T45CR Lower byte Internal data bus Upper byte
Comparator CP7
Match detection
TREG7
Lower byte
TMP93CS40/TMP93CS41
2004-02-10
TMP93CS40/TMP93CS41
7
T4MOD (0038H) Bit symbol Read/Write After reset Function 0
TFF5 invert trigger 0: Disable trigger 1: Enable trigger Inverted when the UC value is latched to CAP2
6
EQ5T5 0 R/W
5
CAP1IN W 1
0: Software capture 1: Don't care
4
R/W 0
Capture timing 00: Disable
3
2
CLE R/W 0
1: UC4 clear enable
1
T4CLK1 R/W 0
00: TI4 01: T1 10: T4 11: T16
0
T4CLK0 0
CAP2T5
CAP12M1 CAP12M0 0
Timer 4 source clock
INT4 occurs at rising edge. 01: TI4 TI5
Inverted when the up counter matches TREG5
INT4 occurs at rising edge. 10: TI4 TI4
INT4 occurs at falling edge. 11: TFF1 TFF1
INT4 occurs at rising edge.
Timer 4 input clock 00 01 10 11 External clock (TI4) T1 T4 T16
Clearing the up counter UC4 0 1 Clear disable Clear by match with TREG5
Figure 3.9.3 16-Bit Timer Mode Control Register (T4MOD) (1/2)
93CS40-133
2004-02-10
TMP93CS40/TMP93CS41
7
T4MOD (0038H) Bit symbol Read/Write After reset Function 0
TFF5 invert trigger 0: Disable trigger 1: Enable trigger Inverted when the UC value is latched to CAP2
6
EQ5T5 0 R/W
5
CAP1IN W 1
0: Software capture 1: Don't care
4
R/W 0
Capture timing 00: Disable
3
2
CLE R/W 0
1: UC4 clear enable
1
T4CLK1 R/W 0
00: TI4 01: T1 10: T4 11: T16
0
T4CLK0 0
CAP2T5
CAP12M1 CAP12M0 0
Timer 4 source clock
INT4 occurs at rising edge. 01: TI4 TI5
Inverted when the up counter matches TREG5
INT4 occurs at rising edge. 10: TI4 TI4
INT4 occurs at falling edge. 11: TFF1 TFF1
INT4 occurs at rising edge.
Capture timing of timer4 Capture control
00 01 Capture disable CAP1 at TI4 rise CAP2 at TI5 rise CAP1 at TI4 rise CAP2 at TI4 fall CAP1 at TFF1 rise CAP2 at TFF1 fall Interrupt occurs at the falling edge of TI4 (INT4) input. Interrupt occurs at the rising edge of TI4 (INT4) input.
INT4 control
Interrupt occurs at the rising edge of TI4 (INT4) input.
10
11
Software capture 0 1 The up counter 4 value is loaded to CAP1 (Software capture) Always read as "1"
Timer flip-flop 5 (TFF5) invert trigger 0 1 Trigger disable (Invert prohibition) Trigger enable (Invert permission)
CAP2T5: Inverted when the up counter value is latched to CAP2 EQ5T5: Inverted when the up counter matches TREG5
Figure 3.9.4 16-Bit Timer Controller Register (T4MOD) (2/2)
93CS40-134
2004-02-10
TMP93CS40/TMP93CS41
7
T4FFCR (0039H) Bit symbol Read/Write After reset Function 1
00: Invert 01: Set 10: Clear TFF5 TFF5 TFF5
6
TFF5C0 W 1
5
CAP2T4 R/W 0
TFF4 invert trigger 0: Disable trigger 1: Enable trigger
Inverted when the UC value is latched to CAP2
4
CAP1T4 R/W 0
3
EQ5T4 R/W 0
2
EQ4T4 R/W 0
1
TFF4C1 W 1
00: Invert 01: Set 10: Clear TFF4 TFF4 TFF4
0
TFF4C0 1
TFF5C1
11: Don't care * Always read as "11"
Inverted when the UC value is latched to CAP1
Inverted when the UC
Inverted when the UC
11: Don't care * Always read as "11"
value matches value matches TREG5 TREG4
Timer flip-flop 4 (TFF4) control 00 01 10 11 Inverts the TFF4 value (Software inversion) Sets TFF4 to "1" Clear TFF4 to "0" Don't care (Always read as "11")
Timer flip-flop 4 (TFF4) invert trigger 0 1 Trigger disable (Invert prohibition) Trigger enable (Invert permission)
CAP2T4: Inverted when the up counter value is latched to CAP2 CAP1T4: Inverted when the up counter value is latched to CAP1 EQ5T4: Inverted when up counter matches TREG5 EQ4T4: Inverted when up counter matches TREG4
Timer flip-flop 5 (TFF5) control 00 01 10 11 Inverts the TFF5 value (Software inversion) Set TFF5 to "1" Clear TFF5 to "0" Don't care (Always read as "11")
Figure 3.9.5 16-Bit Timer 4 F/F Control (T4FFCR)
93CS40-135
2004-02-10
TMP93CS40/TMP93CS41
7
T5MOD (0048H) Bit symbol Read/Write After reset Function
6
5
CAP3IN W 1
0: Software capture 1: Don't care
4
R/W 0
Capture timing 00: Disable
3
2
CLE R/W 0
1: UC5 clear enable
1
T5CLK1 R/W 0
00: TI6 01: T1 10: T4 11: T16
0
T5CLK0 0
CAP34M1 CAP34M0 0
Timer 5 source clock
INT6 occurs at rising edge 01: TI6 TI7
INT6 occurs at rising edge. 10: TI6 TI6
INT6 occurs at falling edge. 11: TFF1 TFF1 INT6 occurs at rising edge.
Timer 5 input clock 00 01 10 11 External clock (TI6) T1 T4 T16
Clearing the up counter UC5 0 1 Clear disable Clear by match with TREG7
Figure 3.9.6 16-Bit Timer Mode Control Register (T5MOD) (1/2)
93CS40-136
2004-02-10
TMP93CS40/TMP93CS41
7
T5MOD (0048H) Bit symbol Read/Write After reset Function
6
5
CAP3IN W 1
0: Software capture 1: Don't care
4
R/W 0
Capture timing 00: Disable
3
2
CLE R/W 0
1: UC5 clear enable
1
T5CLK1 R/W 0
00: TI6 01: T1 10: T4 11: T16
0
T5CLK0 0
CAP34M1 CAP34M0 0
Timer 5 source clock
INT6 occurs at rising edge. 01: TI6 TI7
INT6 occurs at rising edge. 10: TI6 TI6
INT6 occurs at falling edge. 11: TFF1 TFF1
INT6 occurs at rising edge.
Timer 5 capture timing Capture control
00 01 Capture disable CAP3 at TI6 rise CAP4 at TI7 rise CAP3 at TI6 rise CAP4 at TI6 fall CAP3 at TFF1 rise CAP4 at TFF1 fall Interrupt occurs at the falling edge of TI6 (INT6) input. Interrupt occurs at the rising edge of TI6 (INT6) input.
INT6 Control
Interrupt occurs at the rising edge of TI6 (INT6) input.
10
11
Software capture 0 1 The up counter 5 value is loaded to CAP3 Always read as "1"
Figure 3.9.7 16-Bit Timer Control Register (T5MOD) (2/2)
93CS40-137
2004-02-10
TMP93CS40/TMP93CS41
7
T5FFCR (0049H) Bit symbol Read/Write After reset Function
6
5
CAP4T6 R/W 0
TFF6 invert trigger 0: Disable trigger 1: Enable trigger Inverted when the UC value is latched to CAP4
4
CAP3T6 R/W 0
3
EQ7T6 R/W 0
2
EQ6T6 R/W 0
1
TFF6C1 W 1
00: Invert 01: Set 10: Clear TFF6 TFF6 TFF6
0
TFF6C0 1
Inverted when the UC value is latched to CAP3
Inverted when the UC value matches TREG7
Inverted when the UC value matches TREG6
11: Don't care * Always read as "11"
Timer flip-flop 6 (TFF6) control 00 01 10 11 Inverts the TFF6 value (Software inversion) Sets TFF6 to "1" Clear TFF6 to "0" Don't care (Always read as "11")
Timer flip-flop 6 (TFF6) invert trigger 0 1 CAP4T6: CAP3T6: EQ7T6: EQ6T6: Trigger disable (Invert prohibition) Trigger enable (Invert permission)
Inverted when the up counter value is latched to CAP4 Inverted when the up counter value is latched to CAP3 Inverted when up counter matches TREG7 Inverted when up counter matches TREG6
Figure 3.9.8 16-Bit Timer 5 F/F Control (T5FFCR)
93CS40-138
2004-02-10
TMP93CS40/TMP93CS41
7
T45CR (003AH) Bit symbol Read/Write After reset Function QCU R/W 0
Warm-up timer control
6
5
4
3
PG1T 0
PG1 shift trigger 0: 8-bit timer trigger (Timers 0, 1) 1: 16-bit trigger (Timer 5) trigger
2
PG0T R/W 0
PG0 shift
1
DB6EN 0
Double buffer 0: Disable 1: Enable Double buffer of TREG6
0
DB4EN 0
0: 8-bit timer trigger (Timers 0, 1) timer
Double buffer of TREG4
timer 1: 16-bit trigger
(Timer 4)
Double buffer control 0 1 Disable Enable
DB6EN: Double buffer of TREG6 DB4EN: Double buffer of TREG4
Selecting PG0 shift trigger 0 1 8-bit timer trigger (Timers 0 and 1) 16-bit timer trigger (Timer 4)
Selecting PG1 shift trigger 0 1 8-bit timer trigger (Timers 0 and 1) 16-bit timer trigger (Timer 5)
Warm-up timer input control 0 1 Uses 7 stage binary counter Does not use 7 stage binary counter (Note 1)
Note 1: In case of not using the 7 stage binary counter as a warm-up timer, a stable clock signal must be input from an external circuit. Note 2: T45CR are always read as "1".
Figure 3.9.9 16-Bit Timer Trigger Control Register (T45CR)
93CS40-139
2004-02-10
TMP93CS40/TMP93CS41
7
TRUN (0020H) Bit symbol Read/Write After reset Function PRRUN R/W 0
6
5
T5RUN 0
4
T4RUN 0
3
P1RUN R/W 0
2
P0RUN 0
1
T1RUN 0
0
T0RUN 0
Prescaler and timer run/stop control 0: Stop and clear 1: Run (Count up)
Count operation 0 1 Stop and clear Count
Note: TRUN is always read as "1".
PRRUN: Operation of prescaler T5RUN: Operation of 16-bit timer (Timer 5) T4RUN: Operation of 16-bit timer (Timer 4) P1RUN: Operation of PWM timer (PWM1/timer 3) P0RUN: Operation of PWM timer (PWM0/timer 2) T1RUN: Operation of 8-bit timer (Timer 1) T0RUN: Operation of 8-bit timer (Timer 0)
7
SYSCR0 Bit symbol (006EH) Read/Write After reset Function
Highfrequency
6
XTEN 0
Lowfrequency High-
5
RXEN 1
Lowfrequency
4
RXTEN 0
frequency
3
RSYSCK R/W 0
Select clock
2
WUEF 0
Warm-up
1
PRCK1 0
0
PRCK0 0
XEN 1
Select prescaler clock input
after release timer (Write) 00: fFPH 1: Start timer 10: fc/16 (Read) 0: End warm up 1: Continue warm up 11: (Reserved)
oscillator (fc) oscillator (fs) oscillator (fc) oscillator (fs) STOP mode 0: Don't care 01: fs 0: Stop 0: Stop after release after release 0: fc
1: Oscillation 1: Oscillation STOP mode STOP mode 1: fs 0: Stop 0: Stop
1: Oscillation 1: Oscillation
Select prescaler clock input 00 fFPH 01 fs 10 fc/16 11 (Reserved) Clock divided by 4
Figure 3.9.10 Timer Operation Control Register/System Clock Control Register
93CS40-140
2004-02-10
TMP93CS40/TMP93CS41
1. Prescaler There are 9-bit prescaler and prescaler clock-selection registers to generate input clock signals for 8-bit timers 0 and 1, 16-bit timers 4 and 5, and serial interfaces 0 and 1. Figure 3.9.11 shows the block diagram. Table 3.9.1 shows prescaler clock resolution into 8-/16-bit timers.
To CPU fFPH
2
To 8-bit PWM prescaler 9-bit prescaler Selector
2 4 8 16 32 64 128 256 512 2 4 T1 T4 T16 T256 T1 T4 T16
To 8-bit timers 0 and 1
XT1
fs
Selector
SYSCR0 Run/stop & clear TRUN
To 16-bit timers 4 and 5
Selector
SYSCR1
2
1 T0 T2 T8 T32
To serial interfaces 0 and 1
fc
fc/2 fc/4 fc/8 fc/16
SYSCR1 X1
/2 /4 /8 /16
Figure 3.9.11 Block Diagram of Prescaler Table 3.9.1 Prescaler Clock Resolution into 8-/16-Bit Timers
at fc = 20 MHz, fs = 32.768 kHz
Select Select Prescaler Clock Gear Value System Clock
1 (fs) 00 0 (fc) (fFPH) XXX 000 (fc) 001 (fc/2) 010 (fc/4) 011 (fc/8) 100 (fc/16) XXX XXX XXX: Don't care Note: The fc/16 clock cannot be used as a prescaler clock when the fs is used as a system clock. 01 (Low-frequency clock) 10 (fc/16 clock) XXX XXX
3
Prescaler Clock Resolution T1
fs/2 (244 s) fc/23 (0.4 s) fc/2 (0.8 s)
4 5
T4
fs/2 (977 s) fc/25 (1.6 s) fc/2 (3.2 s)
6 7
T16
fs/2 (3.9 ms) fc/27 (6.4 s) fc/2 (12.8 s)
8
T256
fs/2 (62.5 ms) fc/211 (102.4 s) fc/212 (204.8 s) fc/213 (409.6 s) fc/214 (819.2 ms)
11
fc/25 (1.6 s) fc/2 (3.2 s)
6 7
fc/27 (6.4 s) fc/2 (12.8 s)
8 9
fc/29 (25.6 s) fc/2 (51.2 s)
10 11
fc/2 (6.4 s) fs/23 (244 s) fc/27 (6.4 s)
fc/2 (25.6 s) fs/25 (977 s) fc/29 (25.6 s) 16-bit timer
fc/2 (102.4 s) fc/215 (1.64 ms) fs/27 (3.9 ms) fs/211 (62.5 ms)
fc/211 (102.4 s) fc/215 (1.64 ms)
8-bit timer
93CS40-141
2004-02-10
TMP93CS40/TMP93CS41
The clock selected from among fFPH, fc/16, and fs is divided by 4 and input to this prescaler. This selection is made by prescaler clock selection register SYSCR0. Resetting sets to 00, selecting the fFPH clock input divided by 4. The 16-bit timers 4 and 5 select among 3 clock inputs: T1, T4, and T16 among the prescaler outputs. This prescaler can be run or stopped by the timer operation control register TRUN. Counting starts when is set to "1". The prescaler is cleared to zero and stops operation when is set to "0". Resetting clears to "0" and stops the prescaler. When the IDLE1 mode (In which only the oscillator operates) is used, set TRUN to "0" to reduce the power consumption of the prescaler before the "HALT" instruction is executed. 2. Up counter The up counter is a 16-bit binary counter which counts up according to the input clock specified by T4MOD register. The alternatives for selecting the input clock include any one of the internal clocks T1, T4, and T16 from the 9-bit prescaler (which is also used as an 8-bit timer), as well as the external clock from the TI4 pin (which itself can also be used as the P80 or INT4 pin). When reset, will be initialized to 00; this selects TI4 input mode. Counting or stop and clear of the counter are controlled by timer operation control register TRUN. When clearing is enabled, up counter UC4 will be cleared each time it matches the timer register TREG5. The "clear enable/disable" setting is made by T4MOD. If clearing is disabled, the counter operates as a free-running counter. 3. Timer registers (TREG4 to TREG7) These two 16-bit registers are used to set the interval time. When the value of up counter UC4 matches the value set in this timer register, the comparator match detect signal will be activated. Setting data in both lower and upper registers are always needed. For example, either by using a 2-byte data transfer instruction, or by using 1-byte data transfer instructions twice: once for the lower 8 bits and once for the upper 8 bits in that order.
93CS40-142
2004-02-10
TMP93CS40/TMP93CS41
TREG4 Upper 8 bits (TREG4H) 000031H TREG6 Upper 8 bits (TREG6H) 000041H Lower 8 bits (TREG6L) 000040H Upper 8 bits (TREG7H) 000043H Lower 8 bits (TREG4L) 000030H Upper 8 bits (TREG5H) 000033H
TREG5 Lower 8 bits (TREG5L) 000032H TREG7 Lower 8 bits (TREG7L) 000042H Timer 5 Timer 4
The TREG4 timer register is a double buffer structure, which is paired with a register buffer. The timer control register T45CR controls whether the double buffer structure should be enabled or disabled. It is disabled when = 0, and enabled when = 1. When the double buffer is enabled, the timing of data transfer from the register buffer to the timer register is at the match between the up counter (UC4) and timer register TREG5. When reset, will be initialized to "0"; this disables the double buffer. To use the double buffer, write data in the timer register, set = 1, and then write the data which follows to the register buffer. TREG4 and the register buffer are allocated to the same memory addresses 000030H/000031H. When = 0, the same value will be written in both the timer register and in the register buffer. When = 1, the value is written only into the register buffer. Therefore, to write the initial value into the timer register, the register buffer should be disabled. 4. Capture registers These 16-bit registers are used to hold the values of the up counter. Data in the capture registers should be read all 16 bits. For example, by a 2-byte data load instruction or by two 1-byte data load instructions, starting from the lower 8 bits followed by the upper 8 bits.
CAP1 Upper 8 bits (CAP1H) 000035H CAP3 Upper 8 bits (CAP3H) 000045H Lower 8 bits (CAP3L) 000044H Upper 8 bits (CAP4H) 000047H Lower 8 bits (CAP1L) 000034H Upper 8 bits (CAP2H) 000037H
CAP2 Lower 8 bits (CAP2L) 000036H CAP4 Lower 8 bits (CAP4L) 000046H Timer 5 Timer 4
93CS40-143
2004-02-10
TMP93CS40/TMP93CS41
5. Capture input control This circuit controls the timing of latching the value of up counter UC4 into CAP1 and CAP2. The latch timing of the capture register is controlled by register T4MOD. There are four possible settings: * * When T4MOD = 00 Capture function is disabled. Disable is the default on resetting. When T4MOD = 01 Data are loaded to CAP1 at the rising edge of the TI4 pin (which is also used as P80 or INT4) input, while data are loaded to CAP2 at the rising edge of the TI5 pin (also used as P81 or INT5) input. (Time difference measurement.) * When T4MOD = 10 Data are loaded to CAP1 at the rising edge of the TI4 pin input, and to CAP2 at the falling edge. Only in this setting, interrupt INT4 occurs at the falling edge. This results in pulse width measurement. * When T4MOD = 11 Data are loaded to CAP1 at the rising edge of timer flip-flop TFF1, and to CAP2 at the falling edge. Besides, the value of the up counter can be loaded to capture registers by software. Whenever "0" is written in T4MOD, the current value of the up counter will be loaded to capture register CAP1. It is necessary to keep the prescaler in RUN mode (TRUN has to be 1). 6. Comparator There are 16-bit comparators which compare the up counter UC4 value with the values set in TREG4 and TREG5 to detect matches. When a match is detected, these comparators generate interrupts INTTR4 or INTTR5 respectively. The up counter UC4 is cleared only when UC4 matches TREG5. The clearing of up counter UC4 can be disabled by setting T4MOD = 0. 7. Timer flip-flop (TFF4) This flip-flop is inverted by the match detect signal from the comparators or the latch signals to the capture registers. Disable or enable of inversion can be set for each element by T4FFCR. TFF4 will be inverted when "00" is written in T4FFCR. Also it is set to "1" when "01" is written, and cleared when "10"S is written. The value of TFF4 can be output to the timer output pin TO4 (which is also used as P82). TFF4 is undefined on resetting. 8. Timer flip-flop (TFF5) This flip-flop is inverted when the comparator detects that the up counter signal (UC4) and the contents of the timer register TREG5 match, or when the contents of the up counter are latched to the capture register CAP2. Disable or enable of inversion can be set for each element by T4MOD. TFF5 will be inverted when "00" is written in T4FFCR. Also it is set to "1" when "01" is written, and cleared when "10" is written. The value of TFF5 can be output to the timer output pin TO5 (also used as P83). TFF5 is undefined on resetting. Note: This flip-flop (TFF5) is contained only in the 16-bit timer 4.
93CS40-144
2004-02-10
TMP93CS40/TMP93CS41
(1) 16-bit timer mode Generating interrupts at fixed intervals: In this example, the interval time is set in the timer register TREG5 to generate the interrupt INTTR5.
7 - 1 1 0 6 X 1 1 0 * * X 5 - 0 0 1 * * - 4 0 0 0 0 3 - 1 0 0 2 - 0 0 1 1 - 0 1 * 0 - 0 1 *
TRUN INTET54 T4FFCR T4MOD TREG5 TRUN

* * 1
(** = 01, 10, 11) ***** ***** 1 - - - -
Stop timer 4. Enable INTTR5 and set interrupt level 4. Disable INTTR4. Disable trigger. Select internal clock for input and disable the capture function. Set the interval time (16 bits). Start timer 4.
X: Don't care, -: No change (2) 16-bit event counter mode In 16-bit timer mode as described in (1) above, the timer can be used as an event counter by selecting the external clock (TI4 pin input) as the input clock. To read the value of the counter, first perform "software capture" once and read the captured value. The counter counts at the rising edge of the TI4 pin input. The TI4 pin can also be used as P80 or INT4.
7 - - 1 1 0 * * TRUN 1 6 X - 1 1 0 * * X 5 - - 0 0 1 * * - 4 0 - 0 0 0 * * 1 3 - - 1 0 0 * * - 2 - - 0 0 1 * * - 1 - - 0 1 0 * * - 0 - 0 0 1 0 * * -
TRUN P8CR INTET54 T4FFCR T4MOD TREG5
Stop timer 4. Set P80 to input mode. Enable INTTR5 and sets interrupt level 4, while disables INTTR4. Disable trigger. Select TI4 as the input clock. Set the number of counts (16 bits). Start timer 4.
Note: When using this set up as an event counter, set the prescaler in RUN mode. (3) 16-bit programmable pulse generation (PPG) output mode The PPG mode is obtained by inversion of the timer flip-flop TFF4 that is enabled by the match of the up counter UC4 with either of the timer registers TREG4 or TREG5. TFF4 is also output to TO4 (which can be alternatively used as P82). In this mode, the following conditions must be satisfied: (Set value of TREG4) < (Set value of TREG5)
93CS40-145
2004-02-10
TMP93CS40/TMP93CS41
T45CR TRUN TREG4 TREG5 T45CR T4FFCR T4MOD P8CR P8FC TRUN
7 0 - * * * * 0 1 0 - X 1
6 X X * * * * X 1 0 - - X
5 X - * * * * X 0 1
4 X 0 * * * * X 0 0
3 - - * * * * - 1 0
2 - - * * * * - 1 1
1 - - * * * * - 0 *
0 0 - * * * * 1 0 * - X -
Disable double buffer of TREG4. Stop timer 4. Set the duty. (16 bits) Set the cycle. (16 bits) Enable double buffer of TREG4. (Change the duty and cycle at the interrupt INTTR5.) Set the mode to invert TFF4 at the match with TREG4 or TREG5, and also set TFF4 to "0". Select the internal clock for the input, and disable the capture function. Assign P82 as TO4. Start timer 4.
(** = 01, 10, 11) ---1- XX-1X -1---
X: Don't care, -: No change
Match with TREG4 (Interrupt INTTR4) Match with TREG5 (Interrupt INTTR5) TO4 pin
Figure 3.9.12 Programmable Pulse Generation (PPG) Output Waveforms When the double buffer of TREG4 is enabled in this mode, the value of register buffer 4 will be shifted into TREG4 on finding a match with TREG5. This feature makes the handling of low duty waves easy.
Match with TREG4 Up counter = Q1 Match with TREG5 Shift into TREG5 TREG4 (Value to be compared) Register buffer Q1 Q2 Up counter = Q2
Q2 Write into TREG4
Q3
Figure 3.9.13 Operation of Register Buffer
93CS40-146
2004-02-10
TMP93CS40/TMP93CS41
Figure 3.9.14 shows the block diagram of this mode.
TRUN
TI4 T1 T4 T16
TO4 (PPG output) TO5 Flip-flop (TFF4) Flip-flop (TFF5)
Selector
16-bit up counter UC4
Clear
Match 16-bit comparator 16-bit comparator
Match
TREG4
Selector TREG4-WR Register buffer 4 T45CR TREG5
Internal data bus
Figure 3.9.14 Block Diagram of 16-Bit PPG Mode (4) Application examples of the capture function It is possible to enable or disable the loading of up counter (UC4) values into the capture registers CAP1 and CAP2, the timer flip-flop TFF4 inversion due to match detection by comparators CP4 and CP5, and the output of the TFF4 status to the TO4 pin. Combined with the interrupt function, these options can be applied in many ways, for example: 1. One-shot pulse output from external trigger pulse 2. Frequency measurement 3. Pulse width measurement 4. Time difference measurement These four application examples are described in detail below.
93CS40-147
2004-02-10
TMP93CS40/TMP93CS41
1. One-shot pulse output from external trigger pulse To program this application, set the up counter UC4 in free-running mode with the internal input clock, input the external trigger pulse from the TI4 pin, and load the value of the up counter into capture register CAP1 at the rising edge of the TI4 pin. Then set T4MOD = 01. When the interrupt INT4 is generated at the rising edge of the TI4 input, set the CAP1 value (c) plus a delay time (d) to TREG4 (= c + d), and set the above set value (c + d) plus a one-shot pulse width (p) to TREG5 (= c + d + p). When the interrupt INT4 occurs, the T4FFCRregister should be set so that the TFF4 inversion is enabled only when the up counter value matches TREG4 or TREG5. When interrupt INTTR5 occurs, this inversion will be disabled.
Set the counter in free-running mode. Counter clock (Internal clock) TI4 pin input (External trigger pulse)
c
c+d
c+d+p
Load the up counter value into capture register 1 (CAP1) when INT4 occurs
Match with TREG4 Enable inversion
Disable inversion caused by loading of the up counter value into CAP1. Enable inversion INTTR5 occurrence
Match with TREG5
Timer output pin TO4
Delay time (d)
Pulse width (p)
Figure 3.9.15 One-shot Pulse Output (with delay)
93CS40-148
2004-02-10
TMP93CS40/TMP93CS41
Setting example: To output a 2 ms one-shot pulse to the external trigger pulse to TI4 pin, with 3 ms delay Clock condition System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: fFPH
Main setting T4MOD - - 1 0 1 0 0 1 Load the up counter value into CAP1 at the rising edge of TI4 pin input. T4FFCR 1 1 0 0 0 0 1 0 Clear TFF4 to zero. Disable TFF4 inversion. P8CR P8FC INTE45 INTET54 TRUN - X - 1 1 - - - 0 X - X - 0 - - X - 0 1 - - 1 1 - 1 1 1 0 - - X 0 0 - - X 0 0 - Select P82 as the TO4 pin. Keep counting (Free running) Count with T1.
Enable INT4, and disable INTTR4 and INTTR5. Start timer 4.
Setting of INT4 TREG4 TREG5 T4FFCR - CAP1 + 3 ms/T1 TREG4 + 2 ms/T1 ---11-
- Enable TFF4 inversion when the up counter value matches TREG4 or TREG5. Enable INTTR5.
INTET54
1
1
0
0
-
-
-
-
Setting of INTTR5 T4FFCR - - - - 0 0 - - Disable TFF4 inversion when the up counter value matches TREG4 or TREG5. Disable INTTR5.
INTET54
1
0
0
0
-
-
-
-
X: Don't care, -: No change
When a delay time is unnecessary, invert the timer flip-flop TFF4 by loading the up counter value into capture register 1 (CAP1). Then set TREG5 to the CAP1 value (c) plus the one-shot pulse width (p) when an INT4 interrupt occurs. The TFF4 inversion should be enabled when the up counter (UC4) value matches TREG5, and disabled when generating the interrupt INTTR5.
93CS40-149
2004-02-10
TMP93CS40/TMP93CS41
Count clock (Internal clock) TI4 pin input (External trigger pulse)
c
c+p INT4 occurrence. Load the up counter value into capture register 1 (CAP1). INTTR5 occurrence
Load the up counter value into capture register 2 (CAP2).
Match with TREG5 Enable inversion Timer output pin TO4 Pulse width Enable inversion caused by loading of the up counter value into CAP1. (p)
Disable inversion caused by loading of the up counter value into CAP2.
Figure 3.9.16 One-shot Pulse Output (without delay) 2. Frequency measurement The frequency of the external clock can be measured in this mode. The clock signal is input through the TI4 pin, and its frequency is measured by the 8-bit timers (Timer 0 and timer 1) and the 16-bit timer/event counter (Timer 4). The TI4 pin input should be selected for the clock input of timer 4. The value of the up counter is loaded into the capture register CAP1 at the rising edge of the timer flip-flop TFF1 of the 8-bit timers (Timer 0 and timer 1). Similarly, the up counter value is loaded into CAP2 at the falling edge of the TFF1 flip-flop. The frequency is calculated by the difference between the values loaded in CAP1 and CAP2, at the moment when an interrupt (INTT0 or INTT1) is generated by either 8-bit timer.
Count clock (Internal clock) TFF1 Loading UC4 into CAP1 C1 C2 C1 C2
C1
C2
Loading UC4 into CAP2 INTT0/INTT1
Figure 3.9.17 Frequency Measurement For example, if the value for the level "1" width of TFF1 of the 8-bit timer is set to 0.5 s and the difference between CAP1 and CAP2 is 100, the frequency will be 100 / 0.5 s = 200 Hz.
93CS40-150
2004-02-10
TMP93CS40/TMP93CS41
3. Pulse width measurement This mode allows measurement of the H level width of an external pulse. While keeping the 16-bit timer/event counter counting (Free running) with the internal clock input, the external pulse is input via the TI4 pin. Then the capture function is used to load the UC4 values into CAP1 and CAP2 on the rising edge and falling edge of the external trigger pulse respectively. The interrupt INT4 occurs at the falling edge of TI4. The pulse width is obtained from the difference between the values of CAP1 and CAP2 and the internal clock cycle. For example, if the internal clock is 0.8 s and the difference between CAP1 and CAP2 is 100, the pulse width will be 100 x 0.8 s = 80 s.
Count clock (Internal clock) TI4 pin (External pulse) Loading UC4 into CAP1 Loading UC4 into CAP2 INT4 C1 C2 C1 C2
C1
C2
Figure 3.9.18 Pulse Width Measurement Note: External interrupt INT4 occurs at the falling edge of the TI4 pin input only in this pulse width measuring mode (T4MOD = 10). In other modes, it occurs at the rising edge.
The width of the L level can be measured from the difference between the first C2 and the second C1 at the second INT4 interrupt. 4. Time difference measurement This mode is used to measure the difference in time between the rising edges of external pulses input via TI4 and TI5. While keeping the 16-bit timer/event counter (Timer 4) counting (Free running) with the internal clock, the UC4 value is loaded into CAP1 on the rising edge of the input pulse to TI4. Then the interrupt INT4 is generated. Similarly, the UC4 value is loaded into CAP2 on the rising edge of the input pulse to TI5, generating the interrupt INT5. The time difference between these pulses can be obtained from the difference between the time counts at which loading the up counter value into CAP1 and CAP2 was performed.
93CS40-151
2004-02-10
TMP93CS40/TMP93CS41
Count clock (Internal clock) TI4 pin input TI5 pin input Loading UC4 into CAP1 Loading UC4 into CAP2 INT4 INT5 Time difference
C1
C2
Figure 3.9.19 Time Difference Measurement (5) Different phased pulses output mode (This mode can be used only with timer 4.) In this mode, signals with any phase can be output by the free-running up counter UC4. When the value in up counter UC4 and the value in TREG4 (TREG5) match, the value in TFF4 (TFF5) is inverted and output to TO4 (TO5).
Counter (Free running) Match with TREG4
Match with TREG5
TO4
TO5
Figure 3.9.20 Phase Output The periods of the output waveforms above (Expressed as counter overflow time) are listed in Table 3.9.2.
93CS40-152
2004-02-10
TMP93CS40/TMP93CS41
Table 3.9.2 Timer Output Periods in Different Phased Pulse Output Mode (Expressed as counter overflow time)
at fc = 20 MHz, fs = 32.768 kHz
System Clock Selected
1 (fs)
Prescaler Clock Selected
Gear Value
XXX 000 (fc)
Counter Overflow Time T1
16.0s 26.21 ms 52.43 ms 104.86 ms 209.72 ms 419.43 ms 16.0 s 419.43 ms
T4
64.0 s 104.86 ms 209.72 ms 419.43 ms 838.86 ms 1.68 s 64.0 s 1.68 s
T16
256.0 s 419.43 ms 838.86 ms 1.68 s 3.36 s 6.71 s 256.0 s 6.71 s
0 (fc)
00 (fFPH)
001 (fc/2) 010 (fc/4) 011 (fc/8) 100 (fc/16)
XXX XXX
01 (Low-frequency clock) 10 (fc/16 clock)
XXX XXX
XXX: Don't care
93CS40-153
2004-02-10
TMP93CS40/TMP93CS41
3.10 Stepping Motor Control/Pattern Generation Port
The TMP93CS40/TMP93CS41 contains two 4-bit hardware stepping motor control/pattern generation channels, PG0 and PG1, (hereinafter called PG) which actuate in synchronization with the (8-bit/16-bit) timers. PG (PG0 and PG1) shares the 8-bit input/output port with P6. The output on channel 0 (PG0) is updated in synchronization with the 8-bit timer 0, 8-bit timer 1, or 16-bit timer 4. The output on channel 1 (PG1) is updated in synchronization with the 8-bit timer 0, the 8-bit timer 1, or the 16-bit timer 5. The PG ports are controlled by the control register (PG01CR) and can select either stepping motor control mode or pattern generation mode. Each bit of P6 can be used for a PG port. PG0 and PG1 can be used independently. Since the two PG channels operate in the same manner, except for the following points, only the operation of PG0 will be explained below.
Differences between PG0 and PG1
PG0
Trigger signal from timer 4
PG1
from timer 5
b7 1-2 excitation b3 SA03
PG03
1/2 excitation
P63/PG03 (P67/PG13)
b6
PG02
P62/PG02 (P66/PG12) Reverse rotation Normal rotation
Internal data bus
b2
SA02
b5
PG01
P61/PG01 (P65/PG11)
b1
SA01
b4
PG00
P60/PG00 (P64/PG10)
b0
SA00
Figure 3.10.1 PG Block Diagram
93CS40-154
2004-02-10
TMP93CS40/TMP93CS41
7
PG01CR Bit symbol (004EH) Read/Write After reset Function
mode
6
CCW1 R/W 0
PG1 rotation direction
5
PG1M 0
PG1 mode (Excitation) 0: 1-step PG1
4
PG1TE 0
trigger input
3
PAT0 0
PG0 write mode 0: 8-bit write 1: 4-bit write PG0
2
CCW0 R/W 0
rotation direction 0: Normal rotation 1: Reverse rotation
1
PG0M 0
PG0 mode (Excitation) 0: 1-step excitation or 2-step excitation 1: 1-to-2 step excitation PG0
0
PG0TE 0
trigger input enable 0: Disable 1: Enable
PAT1 0
PG1 write
0: 8-bit write 0: Normal 1: 4-bit write rotation 1: Reverse rotation
excitation enable or 2-step 0: Disable excitation 1: Enable 1: 1-to-2 step excitation
PG0 trigger input enable 0 1 Trigger input disable for PG0 Trigger input enable for PG0
Set the operation mode for PG0 0 1 1- or 2-step excitation (Full step) 1-to-2 step excitation (Half step)/PG mode
PG0 (Stepping motor control) rotation direction control 0 1 Normal rotation/PG mode Reverse rotation
Selecting PG0 write mode 0 1 8-bit write 4-bit write/PG mode (Only the shift alternate register can be written.)
Figure 3.10.2 Pattern Generation Control Register (PG01CR) (1/2)
93CS40-155
2004-02-10
TMP93CS40/TMP93CS41
7
PG01CR Bit symbol (004EH) Read/Write After reset Function
mode
6
CCW1 R/W 0
direction
5
PG1M 0
(Excitation) 0: 1-step excitation or 2-step excitation 1: 1 to 2 step excitation
4
PG1TE 0
PG1 trigger input enable mode 0: Disable 1: Enable
3
PAT0 0
PG0 write
2
CCW0 R/W 0
direction
1
PG0M 0
(Excitation) 0: 1-step excitation or 2-step excitation 1: 1 to 2 step excitation
0
PG0TE 0
PG0 trigger input enable 0: Disable 1: Enable
PAT1 0
PG1 write
PG1 rotation PG1 mode
PG0 rotation PG0 mode
0: 8-bit write 0: Normal 1: 4-bit write rotation 1: Reverse rotation
0: 8-bit write 0: Normal 1: 4-bit write rotation 1: Reverse rotation
PG1 trigger input enable 0 1 Trigger input disable for PG1 Trigger input enable for PG1
Set the operation mode for PG1 0 1 1- or 2-step excitation (Full step) 1-to-2 step excitation (Half step)/PG mode
PG1 (Stepping motor control) Rotating direction control 0 1 Normal rotation/PG mode Reverse rotation
Selecting PG1 write mode 0 1 8-bit write 4-bit write/PG mode (Only the shift alternate register can be written.)
Figure 3.10.3 Pattern Generation Control Register (PG01CR) (2/2)
93CS40-156
2004-02-10
TMP93CS40/TMP93CS41
7
PG0REG (004CH) Bit symbol Read/Write After reset
Prohibit readmodifywrite
6
PG02 W 0
5
PG01 0
4
PG00 0
3
SA03
2
SA02 R/W Undefined
1
SA01
0
SA00
PG03 0
Function
Pattern generation 0 (PG0) output latch register PG0 can be read by reading the port (P6) that is assigned to PG
Shift alternate register 0 for the PG mode (4-bit write) register
Figure 3.10.4 Pattern generation 0 register (PG0REG)
7
PG1REG (004DH) Bit symbol Read/Write After reset
Prohibit readmodifywrite
6
PG12 W 0
5
PG11 0
4
PG10 0
3
SA13
2
SA12 R/W Undefined
1
SA11
0
SA10
PG13 0
Function
Pattern generation 1 (PG1) output latch register PG1 can be read by reading the port (P6) that is assigned to PG
Shift alternate register 1 for the PG mode (4-bit write) register
Figure 3.10.5 Pattern Generation 1 Register (PG1REG)
93CS40-157
2004-02-10
TMP93CS40/TMP93CS41
7
T45CR (003AH) Bit symbol Read/Write After reset Function QCU R/W 0
Watchdog/ warm-up timer control
6
5
4
3
PG1T 0
PG1 shift trigger 0: 8-bit timer trigger (Timers 0 and 1) 1: 16-bit timer trigger (Timer 5)
2
PG0T R/W 0
PG0 shift trigger 0: 8-bit timer trigger (Timers 0 and 1) 1: 16-bit timer trigger (Timer 4)
1
DB6EN 0
Double buffer 0: Disable 1: Enable
0
DB4EN 0
Double buffer for TREG6
Double buffer for TREG4
Double buffer control 0 1 Disable Enable
DB6EN: Double buffer for TREG6 DB4EN: Double buffer for TREG4 Selecting PG0 shift trigger 0 1 8-bit timer trigger (Timers 0 and 1) 16-bit timer trigger (Timer 4)
Selecting PG1 shift trigger 0 1 8-bit timer trigger (Timers 0 and 1) 16-bit timer trigger (Timer 5)
Watchdog timer/warm-up timer input control 0 1 7-stage binary counter used 7-stage binary counter not used (Note 1)
Note 1: When the 7-stage binary counter is not used as a warm-up timer, a stable clock must be input from an external circuit. Note 2: T45CR are always 1.
Figure 3.10.6 16-Bit Timer Trigger Control Register (T45CR)
93CS40-158
2004-02-10
TMP93CS40/TMP93CS41
8-bit timer (Timers 0 and 1)
A Select B S
PG0
Port 60 to 63
16-bit timer 4 A 16-bit timer 5 Select B S PG1 Port 64 to 67

Figure 3.10.7 Connection between Timer and Pattern Generator (1) Pattern generation mode When PG01CR = "1", PG functions as a pattern generator. In this mode data is written from the CPU to the shift alternate register only. The pattern data is then written from the shift alternate register to the pattern generator register synchronized to the shift trigger interrupt from the timer. In this mode, PG01CR should be set to "1", PG01CR to "0", and PG01CR to "1". The output from the pattern generator goes to port 6; since port or functions can be switched by the bit settings in the port function control register, P6FC, any port pin can be assigned to pattern generator output. Figure 3.10.8 shows the block diagram for this mode.
Trigger signal from timer/ timer interrupt
Writing data to SA03 to SA00 on timer interrupt
Shift alternate register output (SA03 to SA00) Pattern generator register output (PG03 to PG00)
n-1
n
Shifting data from SA03 to 00 to PG03 to PG00
n+1
n+2
n+3
n-1
n
n+1
n+2
Example of Pattern Generation Mode
93CS40-159
2004-02-10
TMP93CS40/TMP93CS41
Shift alternate register
PG03
PG03 (P63)
BUS3
SA03
PG02
PG02 (P62)
BUS2 Internal data bus
SA02
PG01
PG01 (P61)
BUS1
SA01
PG00
PG00 (P60)
BUS0
SA00
Shift performed on shift trigger from timer
Figure 3.10.8 Pattern Generation Mode Block Diagram (PG0) In pattern generation mode, only writing to the output latch can be disabled by hardware. All other functions behave in the same way as 1 to 2 step excitation in stepping motor control port mode. Hence, data shifted on the trigger signal from a timer must be written before the next trigger signal is output.
93CS40-160
2004-02-10
TMP93CS40/TMP93CS41
(2) Stepping motor control mode 1. 4-phase 1-step/2-step excitation Figure 3.10.9 and Figure 3.10.10 show the output waveforms for 4-phase 1 excitation and 4-phase 2 excitation respectively when channel 0 (PG0) is selected. a. Normal rotation
Trigger signal from timer PG00 (P60) b4 b7 b6 b5 b4
PG01 (P61) PG02 (P62) PG03 (P63)
b5
b4
b7
b6
b5
b6
b5
b4
b7
b6
b7
b6
b5
b4
b7
Initial value of PG0REG = 0100xxxx
Note:
bn indicates the initial value of PG0REG b7 b6 b5 b4xxxx
b. Reverse rotation
Trigger signal from timer PG00 (P60) b4 b5 b6 b7 b4
PG01 (P61) PG02 (P62) PG03 (P63)
b5
b6
b7
b4
b5
b6
b7
b4
b5
b6
b7
b4
b5
b6
b7
Initial value of PG0REG = 0100xxxx
Figure 3.10.9 Output Waveforms for 4-Phase 1-Step Excitation (Normal rotation and reverse rotation)
93CS40-161
2004-02-10
TMP93CS40/TMP93CS41
Trigger signal from timer PG00 (P60) b4 b7 b6 b5 b4
PG01 (P61) PG02 (P62) PG03 (P63)
b5
b4
b7
b6
b5
b6
b5
b4
b7
b6
b7
b6
b5
b4
b7
Initial value of PG0REG = 1100xxxx
Figure 3.10.10 Output Waveforms for 4-phase 2-step Excitation (Normal rotation) The output from PG0 (P6) is latched on the rising edge of the trigger signal from the timer. The direction of shift is specified by the setting of PG01CR: Normal rotation (PG00PG01PG02PG03) is selected when is set to "0"; reverse rotation (PG00PG01PG02PG03) is selected when is set to "1". 4-phase 1-step excitation will be selected when only one bit is set to "1" during the initialization of PG, while 4-phase 2-step excitation will be selected when two consecutive bits are set to "1". The value in the shift alternate registers are ignored when 4-phase 1-step/2-step excitation mode is selected. Figure 3.10.11 shows the block diagram.
PG0 output latch Shift alternate register b7 b3 Internal data bus b6 b2 b5 b1 b4 b0 SA00 Indicates that shifting takes place on the rising edge of the trigger signal from the timer. SA02 PG01 SA01 PG00 PG00 (P60) PG01 (P61) SA03 PG02 PG02 (P62) PG03 PG03 (P63)
Figure 3.10.11 Block Diagram for 4-phase 1-step Excitation/2-step Excitation (Normal rotation)
93CS40-162
2004-02-10
TMP93CS40/TMP93CS41
2. 4-phase 1 to 2 step excitation Figure 3.10.12 shows the output waveforms for 4-phase 1-2 step excitation when channel 0 is selected. a. Normal rotation
Trigger signal from timer b4 PG00 (P60) b5 PG01 (P61) PG02 (P62) PG03 (P63) b6 b2 b5 b1 b4 b0 b7 b3 b1 b4 b0 b7 b3 b6 b2 b0 b7 b3 b6 b2 b5 b1
b7
b3
b6
b2
b5
b1
b4
b0
Initial value of PG0REG = 11001000
Note:
bn denotes the initial value PG0REG b7 b6 b5 b4 b3 b2 b1 b0
b. Reverse rotation
Trigger signal from timer PG00 (P60) b4 b1 b5 b2 b6 b3 b7 b0
PG01 (P61) PG02 (P62) PG03 (P63)
b5
b2
b6
b3
b7
b0
b4
b1
b6
b3
b7
b0
b4
b1
b5
b2
b7
b0
b4
b1
b5
b2
b6
b3
Initial value of PG0REG = 11001000
Figure 3.10.12 Output Waveforms for 4-phase 1- to 2-step Excitation (Normal rotation and reverse rotation)
93CS40-163
2004-02-10
TMP93CS40/TMP93CS41
The initialization sequence for 4-phase 1-2 step excitation is as follows. By rearranging the initial value b7 b6 b5 b4 b3 b2 b1 b0 to b7 b3 b6 b2 b5 b1 b4 b0, three consecutive bits are set to 1 and the other bits are set to 0 (Positive logic). For example, if b7, b3, and b6 are set to 1, the initial value becomes 11001000, producing the output waveforms shown in Figure 3.10.12. To generate a negative logic output waveform, the 1's and 0's in the initial value must be inverted. For example, to change the output waveform shown in Figure 3.10.12 negative logic, change the initial value to 00110111. The operation will be explained below for channel 0. The output from PG0 (P6) and from the shift alternate register (SA0) for pattern generation is latched on the rising edge of the trigger signal from the timer. The shift direction is set by PG01CR. Figure 3.10.13 shows the block diagram.
PG0 output latch Shift alternate register b7 PG03 PG03 (P63)
b3
SA03
b6 Internal data bus
PG02
PG02 (P62)
b2
SA02
b5
PG01
PG01 (P61)
b1
SA01
b4
PG00
PG00 (P60)
b0
SA00 Indicates that shifting takes place on the rising edge of the trigger signal from the timer.
Figure 3.10.13 Block Diagram for 4-phase 1- to 2-step Excitation (Normal rotation)
93CS40-164
2004-02-10
TMP93CS40/TMP93CS41
Setting example: To drive channel 0 (PG0) using 4-phase 1-2 step excitation (Normal rotation) when timer 0 is selected, set each register as follows.
7 - 0 X * - - - 6 X 0 X * - - - 1 X 5 - X X * - - - 0 - 4 - X 0 * - - - 0 - 3 - - 1 * 1 1 0 1 - 2 - - 0 * 1 1 0 0 - 1 - 0 1 * 1 1 1 0 - 0 0 1 0 * 1 1 1 0 1
TRUN TMOD TFFCR TREG0 P6CR P6FC PG01CR PG0REG TRUN
Stop timer 0, and clear it to zero. Set 8-bit timer mode and select T1 as the input clock for timer 0. Clear TFF1 to zero and enable the inversion trigger using timer 0. Set the cycle in the timer register. Set bits P60 to P63 to output mode. Set bits P60 to P63 to PG output. Select PG0 4-phase 1 to 2 step excitation mode and normal rotation. Set an initial value. Start timer 0.
1 1
X: Don't care, -: No change (3) Trigger signal from timer The trigger signal from the timer used by PG is not the same as the trigger signal for the timer flip-flop (TFF1, TFF4, TFF5, and TFF6); they differ as shown in Table 3.10.1 depending on the operation mode of the timer. Table 3.10.1 Trigger Signal Selection TFF1 Inversion
Selected by TFFCR when the up counter value matches TREG0 or TREG1 value When the up counter value matches both TREG0 and TREG1 values (the value of up counter = TREG1 x 28 + TREG0) When the up counter value matches both TREG0 and TREG1 When the up counter value matches TREG0 value and PWM cycle
PG Shift
Selected by TFFCR when the up counter value matches TREG0 or TREG1 value When the up counter value matches both TREG0 and TREG1 values (the value of up counter = TREG1 x 28 + TREG0) When the up counter value matches TREG1 value (PPG cycle) Trigger signal for PG is not generated
8-bit timer mode
16-bit timer mode
PPG output mode PWM output mode
Note: To shift PG, TFFCR must be set to 1 to enable TFF1 inversion. Channel 1 of PG can be synchronized with the 16-bit timer timer 4/timer 5. In this case, the PG shift trigger signal from the 16-bit timer is output only when the up counter UC4/UC5 value matches TREG5/TREG7.
93CS40-165
2004-02-10
TMP93CS40/TMP93CS41
When using a trigger signal from timer 4, set either T4FFCR or T4MOD to "1"; a trigger is generated when the value in UC4 and the value in TREG5 match. When using a trigger signal from timer 5, set T5FFCR to "1"; a trigger is generated when the value in UC5 and the value in TREG7 match. (4) Application of PG and timer output As explained in the previous section trigger signal from timer, the timings for shifting PG and inverting TFF differ depending on the timer mode. An application which operates PG while operating an 8-bit timer in PPG mode is explained below. To drive a stepping motor, a synchronizing signal is required for the excitation timing, in addition to the value of each phase (PG output). In this application, port 6 is used as a stepping motor control port to output a synchronizing signal to the TO1 pin (shared with P71).
TREG1 TO1 (P71) TREG0 PG00 (P60) PG01 (P61)
PG02 (P62)
PG03 (P63)
Figure 3.10.14 Output Waveforms for 4-Phase 1-step Excitation Setting example:
TRUN TMOD TFFCR TREG0 TREG1 P7CR P7FC P6CR P6FC PG01CR PG0REG TRUN 7 - 1 X * * X X - - - * 1 6 X 0 X * * X X - - - * X 5 - X X * * X X - - - * - 4 - X 0 * * X X - - - * - 3 - X 0 * * - - 1 1 0 * - 2 - X 1 * * - - 1 1 0 * - 1 0 0 1 * * 1 1 1 1 0 * 1 0 0 1 X * * - X 1 1 1 * 1 Stop timer 0, and clear it to zero. Set timer 0 and timer 1 to PPG output mode and select T1 as the input clock. Enable TFF1 inversion and set TFF1 to "1". Set the duty of TO1 to TREG0. Set the cycle of TO1 to TREG1. Assign P71 as TO1. Assign P60 to P63 as PG0. Set PG0 to 4-phase 1-step excitation mode. Set an initial value. Start timer 0 and timer 1.
X: Don't care, -: No change
93CS40-166
2004-02-10
TMP93CS40/TMP93CS41
3.11 Serial Channel
The TMP93CS40/TMP93CS41 includes two serial I/O channels. Channel 0 and channel 1 select UART mode (Asynchronous transmission) or I/O interface mode (Synchronous transmission). The serial channel has the following operation modes: * * I/O interface mode (Channel 0 and 1) UART mode (Channel 0 and 1) Mode 0: Transmission and reception of extended I/O data and synchronizing signal (SCLK). Mode 1: 7-bit data Mode 2: 8-bit data Mode 3: 9-bit data
In mode 1 and mode 2, a parity bit can be added. Mode 3 has a wake-up function for making the master controller start slave controllers in a serial link (multi-controller) system. Figure 3.11.1 shows the data format for each mode. Serial channels 0 and 1 can be used independently. All channels operate in the same manner except for the following points. Hence only the operation of channel 0 is explained below. Differences between channel 0 and 1 Channel 0
Pin name Handshake function TXD0 (P90), RXD0 (P91) CTS0 /SCLK0 (P92) Yes
Channel 1
TXD1 (P93), RXD1 (P94) SCLK1 (P95) No (No CTS pin)
Note: Using the handshake function allows transmission in the units of one data format. Thus overrun error is prevented. See the section entitled handshake function for details.
93CS40-167
2004-02-10
TMP93CS40/TMP93CS41
* Mode 0 (I/O interface mode) Bit0 1 2 3 4 5 6 7
Transfer direction * Mode 1 (7-bit UART mode) No parity Start Bit0 1 2 3 4 5 6 Stop
Parity
Start
Bit0
1
2
3
4
5
6
Parity
Stop
* Mode 2 (8-bit UART mode) No parity Start Bit0 1 2 3 4 5 6 7 Stop
Parity
Start
Bit0
1
2
3
4
5
6
7
Parity
Stop
* Mode 3 (9-bit UART mode) Start Bit0 1 2 3 4 5 6 7 8 Stop
Start
Bit0
1
2
3
4
5
6
7
Bit8
Stop (Wakeup)
When bit8 = 1, an address (Select code) is denoted. When bit8 = 0, data is denoted.
Figure 3.11.1 Data Formats
93CS40-168
2004-02-10
TMP93CS40/TMP93CS41
The serial channel has buffer registers for temporarily storing transmitted or received data during transmitting and receiving operations. This is so that transmitting and receiving operations can be performed independently (Full duplex). However, in I/O interface mode, the SCLK (Serial clock) pin is used for both transmitting and receiving and the channel becomes half duplex. The receiving data register is a double buffer structure that prevents the occurrence of overrun errors and provides a margin of one frame before the CPU reads the received data. The receiving data register stores the previously received data while the buffer register receives the next frame. By using CTS and RTS (There is no RTS pin, so any single port must be controlled by software), it is possible to halt data transmission until the CPU finishes reading received data wherever a frame is received (The handshake function). In UART mode, an additional check function ensures that erroneous state bits caused by noise do not cause receiving operations to start. The channel starts receiving data only when the start bit is detected properly at least twice out of three samplings of the start bit. When the transmission buffer becomes empty and requests the CPU to send the next transmission data, or when data is stored in the receiving data register and the CPU is requested to read the data, an INTTX (Transmit interrupt) or INTRX (Receive interrupt) interrupt occurs. If an overrun error, parity error or framing error occurs during a receiving operation, the flag SC0CR is set. The serial channel 0/1 has a special baud rate generator, which can set any baud rate by dividing the frequency of the four clocks (T0, T2, T8, and T32) from the 9-bit prescaler (shared by the 8-bit/16-bit timers) by a value from 2 to 16. In I/O interface mode, it is possible to input synchronous signals, as well as transmit or receive data using an external clock.
3.11.1
Control Registers
The serial channels are controlled by three control registers: SC0CR, SC0MOD and BR0CR. Transmitted and received data are stored in the register SC0BUF.
93CS40-169
2004-02-10
TMP93CS40/TMP93CS41
7
SC0MOD (0052H) Bit symbol Read/Write After reset Function Undefind
Transfer data bit8
6
CTSE 0
Handshake 0: CTS disable 1: CTS enable
5
RXE 0
Receiving function 0: Receive disable 1: Receive enable
4
WU R/W 0
Wake-up function 0: Disable 1: Enable
3
SM1 0
mode
2
SM0 0
1
SC1 0
(UART) 00: TO0 trigger
0
SC0 0
TB8
Serial transmission
Serial transmission clock
00: I/O interface mode 01: 7-bit UART 10: 8-bit UART 11: 9-bit UART
01: Baud rate generator 10: Internal clock 1 11: Don't care
Serial transmission clock source (UART) 00 01 10 11 Timer 0 match detect signal Baud rate generator Internal clock 1 Don't care
Clock selection for the I/O interface mode is controlled by the serial control register (SC0CR). Serial transmission mode 00 01 10 11 Wake-up function 9-bit UART 0 1 Interrupt when data is received Interrupt only when RB8 = 1 Other modes UART mode I/O interface mode 7-bit length 8-bit length 9-bit length
Don't care
Receiving function 0 1 Receive disable Receive enable
Handshake function ( CTS pin) 0 1 Disable (Always transferable) Enable
Transmission data bit8 Note: SC1MOD (56H) is on channel 1.
Figure 3.11.2 Serial Mode Control Register (Channel 0, SC0MOD)
93CS40-170
2004-02-10
TMP93CS40/TMP93CS41
7
SC0CR (0051H) Bit symbol Read/Write After reset Function RB8 R Undefined Received data bit8
6
EVEN R/W 0 Parity 0: Odd 1: Even
5
PE 0 Parity addition 0: Disable 1: Enable
4
OERR 0
3
PERR 0 1: Error
2
FERR 0
1
SCLKS R/W 0 0: SCLK0
0
IOC 0 0: Baud rate generator 1: SCLK0 pin input
R (Cleared to zero when read)
1: SCLK0 Overrun Parity Framing
Select I/O interface input clock 0 1 Baud rate generator SCLK0 pin input
Edge selection for SCLK pin (Input mode only) Transmits and receives ( ) (Note 1) 0 data on rising edge of SCLK0 1 Transmits and receives ( ) data on falling edge of SCLK0
Framing error flag Parity error flag Overrun error flag
Cleared to zero when read.
Enable parity addition 0 1 Disable Enable
Addition/check of even parity 0 1 Odd parity Even parity
Receiving data bit8 Note 1: Serial control register for channel 1 is SC1CR (55H). Note 2: As all error flags are cleared after reading, do not test a single bit only with a bit-testing instruction.
Figure 3.11.3 Serial Control Register (Channel 0, SC0CR)
93CS40-171
2004-02-10
TMP93CS40/TMP93CS41
BR0CR (0053H)
7
Bit symbol Read/Write After reset Function - R/W 0 Always fixed to 0
6
5
BR0CK1 0 00: T0 01: T2 10: T8 11: T32
4
BR0CK0 0
3
BR0S3 R/W 0
2
BR0S2 0
1
BR0S1 0
0
BR0S0 0
Divided frequency setting
Baud rate generator divided frequency setting 0000 0001 0010 to 1111 16 divisions Invalid 2 to 15 divisions
Baud rate generator input clock selection 00 01 10 11 Note 1: Serial control register for channel 1 is BR1CR (57H). Note 2: Set TRUN to 1 when the baud rate generator is used. Note 3: BR0CR is always 1. Note 4: Don't read from or write to BR0CR register during sending or receiving. Internal clock T0 Internal clock T2 Internal clock T8 Internal clock T32
Figure 3.11.4 Serial Channel Control (Channel 0, BR0CR)
7 TB7 SC0BUF (0050H)
6 TB6
5 TB5
4 TB4
3 TB3
2 TB2
1 TB1
0 TB0 (Transmission)
7 RB7
6 RB6
5 RB5
4 RB4
3 RB3
2 RB2
1 RB1
0 RB0 (Receiving)
Note: Read-modify-write is prohibited for SC0BUF.
Figure 3.11.5 Serial Transmission/Receiving Buffer Registers (Channel 0, SC0BUF)
93CS40-172
2004-02-10
TMP93CS40/TMP93CS41
7
SC1MOD (0056H) Bit symbol Read/Write After reset Function Undefined
Transferred data bit8
6
- 0
Always fixed to 0
5
RXE 0
Receiving function 0: Receive disable 1: Receive enable
4
WU R/W 0
Wake-up function 0: Disable 1: Enable
3
SM1 0
mode
2
SM0 0
1
SC1 0
(UART) 00: TO0 trigger
0
SC0 0
TB8
Serial transmission
Serial transmission clock
00: I/O interface mode 01: 7-bit UART 10: 8-bit UART 11: 9-bit UART
01: Baud rate generator 10: Internal clock 1 11: Don't care
Serial transmission clock source (UART) 00 01 10 11 Timer 0 match detect signal Baud rate generator Internal clock 1 Don't care
Note: Clock selection for the I/O interface mode is controlled by the serial control register (SC1CR). Serial transmission mode 00 01 10 11 Wakeup function 9-bit UART 0 1 Interrupt when data is received Interrupt only when RB8 = 1 Other modes UART mode I/O interface mode 7-bit length 8-bit length 9-bit length
Don't care
Receiving control 0 1 Receive disable Receive enable
Transmission data bit8
Figure 3.11.6 Serial Mode Control Register (Channel 1, SC1MOD)
93CS40-173
2004-02-10
TMP93CS40/TMP93CS41
7
SC1CR (0055H) Bit symbol Read/Write After reset Function RB8 R Undefined Received data bit8
6
EVEN R/W 0 Parity 0: Odd 1: Even
5
PE 0 Parity addition 0: Disable 1: Enable
4
OERR 0
3
PERR 0 1: Error
2
FERR 0
1
SCLKS R/W 0 0: SCLK1
0
IOC 0 0: Baud rate generator 1: SCLK1 pin input
R (Cleared to zero when read)
Overrun
Parity
Framing
1: SCLK1
Select I/O interface input clock 0 1 Baud rate generator SCLK1 pin input
Edge selection for SCLK pin (Input mode only) 0 1 Transmits and receives ( data on rising edge of SCLK1 )
Transmits and receives ( ) data on falling edge of SCLK1
Framing error flag Parity error flag Overrun error flag
Cleared to zero when read
Enable parity addition 0 1 Disable Enable
Addition/check of even parity 0 1 Odd parity Even parity
Receiving data bit8
Note: As all error flags are cleared after reading, do not test a single bit only with a bit-testing instruction.
Figure 3.11.7 Serial Control Register (Channel 1, SC1CR)
93CS40-174
2004-02-10
TMP93CS40/TMP93CS41
7
BR1CR (0057H) Bit symbol Read/Write After reset Function - R/W 0 Always fixed to 0
6
5
BR1CK1 0 00: T0 01: T2 10: T8 11: T32
4
BR1CK0 0
3
BR1S3 R/W 0
2
BR1S2 0
1
BR1S1 0
0
BR1S0 0
Divided frequency setting
Baud rate generator divided frequency setting 0000 0001 0010 to 1111 16 divided Invalid 2 to 15 divisions
Baud rate generator input clock selection 00 01 10 11 Internal clock T0 Internal clock T2 Internal clock T8 Internal clock T32
Note 1: To use baud rate generator, set TRUN to "1", putting the prescaler in RUN. Note 2: BR1CR is always "1". Note 3: Don't read from or write to BR1CR register during sending or receiving.
Figure 3.11.8 Baud Rate Generator Control Register (Channel 1, BR1CR)
7 TB7 SC1BUF (0054H)
6 TB6
5 TB5
4 TB4
3 TB3
2 TB2
1 TB1
0 TB0 (Transmission)
7 RB7
6 RB6
5 RB5
4 RB4
3 RB3
2 RB2
1 RB1
0 RB0 (Receiving)
Note: Read-modify-write is prohibited for SC1BUF.
Figure 3.11.9 Serial Transmission/Receiving Buffer Registers (Channel 1, SC1BUF)
93CS40-175
2004-02-10
TMP93CS40/TMP93CS41
7
P9FC (001DH) Bit symbol Read/Write After reset Function
6
5
P95F W 0 0: Port 1: SCLK1
4
3
P93F W 0 0: Port 1: TXD1
2
P92F W 0 0: Port 1: SCLK0
1
0
P90F W 0 0: Port 1: TXD0
Read-modify-write is prohibited Setting P90 as TXD0 output 0 1 Port TXD0 (Channel 0) output
Setting P92 as SCLK0 output 0 1 Port SCLK0 (Channel 0) output
Setting P93 as TXD1 output 0 1 Port TXD1 (Channel 1) output
Setting P95 as SCLK1 output 0 1 Port SCLK1 (Channel 1) output
Figure 3.11.10 Port 9 Function Register (P9FC)
7
ODE (0058H) Bit symbol Read/Write After reset Function
6
5
4
3
2
1
ODE1 R/W 0 P93 0: CMOS 1: Open drain
0
ODE0 0 P90 0: CMOS 1: Open drain
Setting P90 as open-drain output 0 1 CMOS output Open-drain output
Setting P93 as open-drain output 0 1 Note: ODE is always "1". CMOS output Open-drain output
Figure 3.11.11 Port 9 Open-drain Enable Register (ODE)
93CS40-176
2004-02-10
TMP93CS40/TMP93CS41 3.11.2 Configuration
Figure 3.11.12 shows the block diagram for serial channel 0.
Serial clock generation circuit BR0CR Prescaler Selector T0 T2 T8 T32 Selector UART SIOCLK Selector TO0TRG (Timer 0 comparator output)
Baud rate generator System clock/fSYS (1) /2 SCLK0 (Shared by P92)
SC0MOD Selector
SC0MOD
I/O interface mode
SC0CR INTRX0 INTTX0 SC0MOD Serial channel interrupt control Transmission counter
(UART only / 16)
SCLK0 (Shared by P92)
Receive counter
(UART only / 16)
RXDCLK SC0MOD Receive control SC0CR Parity control RXD0 (Shared by P91)
Receive buffer 1 (Shift register)
TXDCLK Transmission control
CTS0
(Shared by P92) SC0MOD Not present in channel 1
RB8 Receive buffer 2 (SC0BUF)
Error flag
TB8
Transmission buffer (SC0BUF)
TXD0 (Shared by P90)
SC0CR Internal data bus Note: SLCK0 pin can only be used for I/O in I/O interface mode.
Figure 3.11.12 Block Diagram of Serial Channel 0
93CS40-177
2004-02-10
TMP93CS40/TMP93CS41
Figure 3.11.13 shows the block diagram for serial channel 1.
Serial clock generation circuit BR1CR

TO0TRG (Timer 0 comparator output) Selector UART Selector
Baud rate generator System clock/fSYS (1) /2 SCLK1 input (Shared by P95) SCLK1 output (Shared by P95)
Prescaler
T0 T2 T8 T32
Selector
SIOCLK
SC1MOD Selector
SC1MOD
I/O interface mode
SC1CR INTRX1 INTTX1 SC1MOD Serial channel interrupt control Transmission counter
(UART only / 16)
Receive counter
(UART only / 16)
RXDCLK SC1MOD Receive control SC1CR Parity control RXD1 (Shared by P94)
Receive buffer 1 (Shift register)
TXDCLK Transmission control
RB8 Receive buffer 2 (SC1BUF)
Error flag
TB8
Transmission buffer (SC1BUF)
TXD1 (Shared by P93)
SC1CR Internal data bus Note: SLCK1 pin can only be used for I/O in I/O interface mode.
Figure 3.11.13 Block Diagram for Serial Channel 1
93CS40-178
2004-02-10
TMP93CS40/TMP93CS41
1. Prescaler 9-bit prescaler and prescaler clock selection registers generate input clocks for 8-bit timer 0, 1, 16-bit timer 4, 5, and serial interface 0, 1. Figure 3.11.15 shows the block diagram. Table 3.11.1 shows how the prescaler clock is resolved into the baud rate generator.
To CPU fFPH
2
To 5-bit prescaler 9-bit prescaler Selector
2 4 8 16 32 64 128 256 512 2 4 T1 T4 T16 T256 T1 T4 T16
To 8-bit timer 0, 1
Selector
XT1
fs
SYSCR0 Run/stop & clear TRUN
To 16-bit timer 4, 5
Selector
SYSCR1
2
1 T0 T2 T8 T32
To serial interface 0, 1
fc fc/2
fc/4 fc/8 fc/16
SYSCR1 X1
/2 /4 /8 /16
Figure 3.11.14 Block Diagram of Prescaler Table 3.11.1 Prescaler Clock Resolution for Baud Rate Generator Select System Clock
1 (fs) 00 0 (fc) (fFPH)
Select Prescaler Clock
Gear Value
XXX 000 (fc) 001 (fc/2) 010 (fc/4) 011 (fc/8) 100 (fc/16)
Prescaler Output Clock Resolution T0
fs/2 fc/2 fc/2 fc/2 fc/2 fc/2 - -
2 2 3 4 5 6
T2
fs/2 fc/2 fc/2 fc/2 fc/2 fc/2
4 4 5 6 7 8
T8
fs/2 fc/2 fc/2 fc/2 fc/2 fc/2
6 6 7 8 9
T32
fs/28 fc/28 fc/29 fc/210 fc/211 fc/212 fs/28 fc/212
10
XXX XXX
01 (Low-frequency clock) 10 (fc/16 clock)
XXX XXX
fs/24 fc/28
fs/26 fc/210
XXX: Don't care, -: Invalid Note: The fc/16 clock cannot be used as a prescaler clock when the fs clock is used as a system clock.
93CS40-179
2004-02-10
TMP93CS40/TMP93CS41
The selected clock (fFPH clock, fc/16 clock or fs clock) is divided by 4 and input to the prescaler. This selection is made by the prescaler clock selection register SYSCR0. Resetting sets to "00" and selects the fFPH clock input divided by 4. The baud rate generator selects between 4 clock inputs: The prescaler outputs T0, T2, T8, and T32. The prescaler can be run or stopped by the timer operation control register TRUN. Counting starts when is set to "1". The prescaler is cleared to zero and stops operation when is set to "0". Resetting clears to "0", clearing the prescaler and stopping operation. When IDLE1 mode (in which only the oscillator operates) is used, set TRUN to "0" to stop the prescaler before a HALT instruction is executed.
93CS40-180
2004-02-10
TMP93CS40/TMP93CS41
2. Baud rate generator The baud rate generator is a circuit that generates transmission and receiving clocks to determine the transfer rate of the serial channel. The input clock to the baud rate generator, T0, T2, T8, or T32, is generated by the 9-bit prescaler which is shared by the timers. One of these input clocks is selected by the baud rate generator control register BR0CR. The baud rate generator includes a 4-bit frequency divider, which divides frequency by from 2 to 16 to determine the transfer rate. The method for calculating a transfer rate when the baud rate generator is used is explained below. * UART mode Baud rate = * Input clock for baud rate generator Frequency divisor for baud rate generator / 16
I/O interface mode Baud rate = Input clock for baud rate generator Frequency divisor for baud rate generator /2
For example, when the source clock (fc) is 12.288 MHz, the input clock is T2 (fc/16), and the frequency divisor is 5, the transfer rate in UART mode is as follows: * Clock configuration System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: fFPH
Baud rate =
fc/16 5
/16
= 12.288 x 106 / 16 / 5 / 16 = 9600 (bps) Table 3.11.2 shows an example of the transfer rate in UART mode. Also, using the 8-bit timer 0, the serial channel can generate a transfer rate. Table 3.11.3 shows examples of baud rate settings using timer 0.
93CS40-181
2004-02-10
TMP93CS40/TMP93CS41
Table 3.11.2 Selection of Transfer Rate (1) (when baud rate generator is used)
Unit (kbps)
Input clock fc [MHz] Frequency divisor
2 9.830400 4 8 0 12.288000 5 A 3 14.745600 6 C 76.800 38.400 19.200 9.600 38.400 19.200 76.800 38.400 19.200 19.200 9.600 4.800 2.400 9.600 4.800 19.200 9.600 4.800 4.800 2.400 1.200 0.600 2.400 1.200 4.800 2.400 1.200 1.200 0.600 0.300 0.150 0.600 0.300 1.200 0.600 0.300
T0
T2
T8
T32
Note 1: Transfer rates in I/O interface mode are 8 times faster than the values given in the above table. Note 2: This table is calculated for when fc is selected as the system clock, the clock gear is set to fc, and the system clock is selected as the prescaler clock input. Table 3.11.3 Selection of Transfer Rate (2) (when timer 0 (Input clock T1) is used)
Unit (kbps)
fc TREG0
1H 2H 3H 4H 5H 8H AH 10H 14H
12.288 MHz
96 48 32 24 19.2 12 9.6 6 4.8
12 MHz
9.8304 MHz
76.8 38.4
8 MHz
62.5 31.25
6.144 MHz
48 24 16 12 9.6 6 4.8 3 2.4
31.25 19.2 9.6 4.8
How to calculate the transfer rate (when timer 0 is used): Transfer rate = Clock frequency selected by SYSCR0 TREG0 x 8 x 16 (when timer 0 (Input clock T1) is used) Note 1: Timer 0 match detect signal cannot be used as the transfer clock in I/O interface mode. Note 2: This table is calculated for when fc is selected as the system clock, the clock gear is set to fc, and fFPH is selected as the prescaler clock input.
93CS40-182
2004-02-10
TMP93CS40/TMP93CS41
3. Serial clock generation circuit This circuit generates the basic clock for transmitting and receiving data. * I/O interface mode In SCLK output mode with a setting of SC0CR = "0", the basic clock is generated by dividing the output of the baud rate generator by 2, as described previously. In SCLK Input mode with setting of SC0CR = "1", the rising edge or falling edge is detected, according to the setting of the SC0CR register, and used to generate the basic clock. * UART mode The setting of SC0MOD selects the baud rate generator clock, internal clock 1 (Max 625 kbps at fc = 20 MHz) or the match detect signal from timer 0 as the signal from which to generate the basic clock SIOCLK. 4. Receiving counter The receiving counter is a 4-bit binary counter used in asynchronous communication (UART) mode and counts up with the SIOCLK clock. A duration of 16 pulses of SIOCLK are used for receiving 1 bit of data, and the data bit is sampled three times, at the 7th, 8th, and 9th clock ticks. Using these three samples, the received data is evaluated using the majority rule. For example, if the sampled data bits are respectively "1", "0" and "1" at the 7th, 8th, and 9th clock ticks, the received data is evaluated as "1". Sampled data "0", "0" and 1 is evaluated to be "0". 5. Receiving control * I/O interface mode In SCLK0 output mode with a setting of SC0CR = "0", the RXD0 signal will be sampled at the rising edge of the shift clock which is output to the SCLK0 pin. In SCLK0 input mode with a setting of SC0CR = "1", the RXD0 signal will be sampled at the rising edge or falling edge of the SCLK0 input, according to the setting of the SC0CR register. * Asynchronous communication (UART) mode The receiving control block has a circuit for detecting the start bit using the majority rule. When two or more 0's are detected out of 3 samples, it is recognized as a start bit and the receiving operation is started. The data being received is also evaluated using the majority rule.
93CS40-183
2004-02-10
TMP93CS40/TMP93CS41
6. Receiving buffer To prevent overrun errors, the receiving buffer has a double buffer structure. Received data is stored bit by bit in receiving buffer 1 (Shift register type). When 7 bits or 8 bits of data are stored in receiving buffer 1, the stored data is transferred to receiving buffer 2 (SC0BUF), generating an interrupt INTRX0. The CPU reads only receiving buffer 2 (SC0BUF). Even before the CPU has read receiving buffer 2 (SC0BUF), more received data can be stored in receiving buffer 1. However, unless receiving buffer 2 (SC0BUF) is read before all the bits of the next data are received by receiving buffer 1, an overrun error occurs. If an overrun error occurs, the contents of receiving buffer 1 will be lost, although the contents of receiving buffer 2 and SC0CR are still preserved. The parity bit added in 8-bit UART mode and the most significant bit (MSB) in 9-bit UART mode are stored in SC0CR. In 9-bit UART mode, the wakeup function for the slave controller is enabled by setting SC0MOD to "1"; and interrupt INTRX0 occurs only when SC0CR is set to 1. 7. Transmission counter The transmission counter is a 4-bit binary counter which is used in Asynchronous communication (UART) mode and, like a receiving counter, counts using the SIOCLK clock. This generates a TXDCLK pulse every 16 clock pulses.
SIOCLK 15 TXDCLK 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2
Figure 3.11.15 Generation of Transmission Clock 8. Transmission controller * I/O interface mode In SCLK0 output mode with a setting of SC0CR = 0, the data in the transmission buffer is output bit by bit to the TXD0 pin at the rising edge of the shift clock which is output from the SCLK0 pin. In SCLK0 Input mode with a setting of SC0CR = 1, the data in the transmission buffer is output bit by bit to the TXD0 pin at the rising edge or falling edge of the SCLK0 input, according to the setting of the SC0CR register. * Asynchronous communication (UART) mode When transmission data is written to the transmission buffer from the CPU, transmission starts at the rising edge of the next TXDCLK pulse.
93CS40-184
2004-02-10
TMP93CS40/TMP93CS41
Handshake function Serial channel 0 has a CTS0 pin. Using this pin, data can be sent in units of one frame; thus, overrun errors can be avoided. The handshake function is enabled/disabled by SC0MOD. When the CTS0 pin goes high, after completion of the current data transmission, data transmission is halted until the CTS0 pin goes low again. When the INTTX0 interrupt is generated, it requests the next data transmission to the CPU. Although there is no RTS pin, a handshake function can easily be configured by assigning any port to the RTS function. The RTS output should be high to request a halt to data transmission after data receive is completed by software in the RXD interrupt routine.
TMP93CS40/S41 TMP93CS40/S41
TXD
CTS
RXD
RTS (Any port)
Sender
Receiver
Figure 3.11.16 Handshake Function
Timing to write to transmission buffer
CTS
Send is suspended from (A) to (B). (A). 13
(B) 15 16 1 2 3 14 15 16 1 2 3
14
SIOCLK
TXDCLK
TXD
Start bit
Bit0
Note 1: If the CTS signal rises during transmission, the next datum is not sent after completion of the current transmission. Note 2: Transmission starts at the first falling edge of the TXDCLK clock after the CTS signal falls.
Figure 3.11.17 Timing of CTS (Clear to send)
93CS40-185
2004-02-10
TMP93CS40/TMP93CS41
9. Transmission buffer The transmission buffer (SC0BUF) shifts out and sends the transmission data written from the CPU in order starting with the least significant bit (LSB). When all bits have been shifted out, the transmission buffer becomes empty and generates an INTTX0 interrupt. 10. Parity control circuit When the serial channel control register SC0CR is set to 1, it is possible to transmit and receive data with parity. However, parity can be added only in 7-bit UART or 8-bit UART modes. The SC0CR register can select even or odd parity. During transmission, parity is automatically generated according to the data written to the transmission buffer SC0BUF. The data are transmitted after the parity bit is stored in SC0BUF in 7-bit UART mode, or in SC0MOD in 8-bit UART mode. and must be set before the transmission data is written to the transmission buffer. During receiving, data are shifted to the receiving buffer 1 and the parity is automatically set after the data are transferred to the receiving buffer 2 (SC0BUF). The parity bit is then compared with SC0BUF in 7-bit UART mode, or with SC0MOD in 8-bit UART mode. If the bits do not match, a parity error occurs and the SC0CR flag is set. 11. Error flag Three error flags are provided to increase the reliability of data reception. 1) Overrun error If all bits of the next datum are received in receiving buffer 1 while valid data is stored in receiving buffer 2 (SC0BUF), an overrun error occurs. 2) Parity error The parity generated for the data shifted into receiving buffer 2 (SC0BUF) is compared with the parity bit received from the RXD pin. If they are not equal, a parity error occurs. 3) Framing error The stop bit of the received data is sampled three times in the center of the pulse. If the majority of the sampled values are "0", a framing error occurs.
93CS40-186
2004-02-10
TMP93CS40/TMP93CS41
12. Signal generating timing 1) In UART mode Receive Mode
Timing for interrupt generation Timing for framing generation Timing for parity error generation Timing for overrun error timing
9 Bits
Around center of bit8 Around center of stop bit - Around center of bit8
8 Bits + Parity
Around center of parity bit Around center of stop bit Around center of parity bit Around center of parity bit
8 Bits, 7 Bits + Parity, 7 Bits
Around center of stop bit Around center of stop bit Around center of stop bit
Note: In 9-Bit and 8-Bit + Parity mode, interrupts coincide with the ninth bit pulse.Thus, when servicing the interrupt, it is necessary to wait for a 1-bit period (to allow the stop bit to be transferred) to allow checking for a framing error. Send Mode
Timing for interrupt generation
9 Bits
Immediately before stop bit sent
8 Bits + Parity
8 Bits, 7 Bits + Parity, 7 Bits
2) In I/O interface mode
Timing for send interrupt generation Timing for receive interrupt generation SCLK0 output mode SCLK0 input mode SCLK0 output mode SCLK0 input mode Immediately after rise of last SCLK0 signal (See Figure 3.9.20) Immediately after rise (Rising mode) or fall (Falling mode) of last SCLK0 signal (See Figure 3.9.21) Immediately after final SCLK0 (when received data are transferred to receive buffer 2 (SC0BUF)) (See Figure 3.9.22) Immediately after final SCLK0 (when received data are transferred to receive buffer 2 (SC0BUF)) (See Figure 3.9.23)
93CS40-187
2004-02-10
TMP93CS40/TMP93CS41 3.11.3 Operational Description
(1) Mode 0 (I/O interface mode) This mode is used to increase the number of I/O pins available for transmitting data to or receiving data from an external shift register. This mode encompasses the SCLK output mode for outputting a synchronous clock SCLK and the SCLK input mode for inputting an external synchronous clock SCLK.
Output extension TMP93CS40 Shift register A B TXD SI C D SCLK SCK E F PORT RCK G H TC74HC595 or equivalent
Input extension TMP93CS40
Shift register
A B
RXD
QH
C D
SCLK
CLOCK
E F
PORT
S/L
G H
TC74HC165 or equivalent
Figure 3.11.18 Example of SCLK Output Mode Connection
Output port extension TMP93CS40 Shift register A B TXD SI C D SCLK SCK E F PORT RCK G H TC74HC595 or equivalent
Input port extension TMP93CS40 Shift register A B RXD QH C D SCLK CLOCK E F PORT S/L G H TC74HC165 or equivalent
External clock
External clock
Figure 3.11.19 Example of SCLK Input Mode Connection
93CS40-188
2004-02-10
TMP93CS40/TMP93CS41
1. Transmission In SCLK output mode, 8-bit data and the synchronous clock are output from the TXD0 pin and SCLK0 pin respectively, each time the CPU writes data to the transmission buffer. When all data has been output, INTES0 will be set, generating the INTTX0 interrupt.
Timing to write transmission data SCLK0 output TXD0 Bit0 Bit1 Bit6 Bit7
TXDSFT ITX0C (INTTX0 interrupt request)
Figure 3.11.20 Transmitting Operation in I/O Interface Mode (SCLK output mode) (Channel 0) In SCLK input mode, 8-bit data are output from the TXD0 pin when SCLK0 input becomes active after data are written to the transmission buffer by the CPU. When all data have been output, INTES0 will be set, generating the INTTX0 interrupt.
SCLK0 input (SCLKS = 0: Rising edge mode)
SCLK0 input (SCLKS = 1: Falling edge mode) TXD0 Bit0 Bit1 Bit5 Bit6 Bit7
TXDSFT
ITX0C (INTTX0 interrupt request)
Figure 3.11.21 Transmitting Operation in I/O Interface Mode (SCLK input mode) (Channel 0)
93CS40-189
2004-02-10
TMP93CS40/TMP93CS41
2. Receiving In SCLK output mode, the synchronous clock is output from the SCLK0 pin and data are shifted into the receiving buffer 1 whenever the receive interrupt flag INTES0 is cleared by a read of the received data. When 8-bit data is received, the data will be transferred to receiving buffer 2 (SC0BUF) according to the timing shown below and INTES0 will be set again, generating an INTRX0 interrupt.
IRX0C
SCLK0 RXD0 Timing to shift data into receiving buffer 2 Bit0 Bit1 Bit2 Bit6 Bit7 Generate INTRX0
Figure 3.11.22 Receiving Operation in I/O Interface Mode (SCLK0 output mode) (Channel 0) In SCLK input mode, the data are shifted to receiving buffer 1 when the SCLK input becomes active after the receive interrupt flag INTES0 is cleared by a read of the received data. When 8-bit data are received, the data will be shifted to receiving buffer 2 (SC0BUF) according to the timing shown below and INTES0 will be set again, generating the INTRX0 interrupt.
SCLK0 input (SCLKS = 0: Rising edge mode)
SCLK0 input (SCLKS = 1: Falling edge mode) RXD0 Timing to shift data into receiving buffer 2 Bit0 Bit1 Bit2 Bit6 Bit7 Generate INTRX0
Figure 3.11.23 Receiving Operation in I/O Interface Mode (SCLK input mode) (Channel 0) Note: When receiving data, the system must be put in receive enable state (SC0MOD = 1).
93CS40-190
2004-02-10
TMP93CS40/TMP93CS41
(2) Mode 1 (7-bit UART mode) 7-bit mode can be selected by setting the serial channel mode register SC0MOD to 01. In this mode, a parity bit can be added. The parity bit is enabled or disabled by serial channel control register SC0CR. Even parity or odd parity is selected using SC0CR when is set to 1 (Enable). Setting example: When transmitting data with the following format, the control registers should be set as described below. Channel 0 is explained here.
Even parity
Start
Bit0
1
2
3
4
5
6
Stop
Direction of transmission (Transmission rate: 2400 bps at fc = 12.288 MHz)
*
Clock configuration System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: System clock
7 6 X X 0 1 X X 1 * 5 - - - 1 1 - 0 * 4 - X X X 0 - 0 * 3 - - 0 X 0 - 2 - X 1 X 1 - 1 - X 0 0 0 - 0 1 1 1 0 1 - Set 7-bit UART mode. Set even parity. Set transfer rate at 2400 bps. Start the prescaler for the baud rate generator. Enable INTTX0 interrupt and set interrupt level 4. Set data for transmission. Select P90 as the TXD0 pin.
P9CR P9FC SC0MOD SC0CR BR0CR TRUN INTES0 SC0BUF

X X X X 0 1 1 *
- *
- *
- *
- *
X: Don't care, -: No change (3) Mode 2 (8-bit UART mode) 8-bit UART mode can be selected by setting SC0MOD to 10. In this mode, a parity bit can be added. The parity bit is enabled or disabled by SC0CR. Even parity or odd parity is selected by using SC0CR when is set to 10 (Enable). Setting example: When receiving data with the following format, the control registers should be set as described below.
Odd parity
Start
Bit0
1
2
3
4
5
6
7
Stop
Direction of transmission (Transmission rate: 9600 bps at fc = 12.288 MHz)
*
Clock configuration System clock: High frequency (fc) Clock gear: 1 (fc) Prescaler clock: System clock
93CS40-191
2004-02-10
TMP93CS40/TMP93CS41
Main setting
7 P9CR SC0MOD SC0CR BR0CR TRUN INTES0 6 X 0 0 X X - 5 - 1 1 0 - 4 - X X 1 - 3 - 1 X 0 - 1 2 - 0 X 1 - 1 1 0 0 0 0 - 0 0 - 1 0 1 - 0

X - X 0 1 -
Select P91 (RXD0) as the input pin. Enable receiving in 8-bit UART mode. Set odd parity. Set transfer rate at 9600 bps. Start the prescaler for the baud rate generator. Enable INTTX0 interrupt and set interrupt level 4.
-
-
Interrupt processing
Acc SC0CR AND 00011100 if Acc 0 then ERROR Acc SC0BUF Check for error. Read the received data.
X: Don't care, -: No change (4) Mode 3 (9-bit UART mode) 9-bit UART mode can be selected by setting SC0MOD to 11. In this mode, a parity bit cannot be set. During transmission, the MSB (9th bit) is written to the serial channel mode register . During receiving it is stored in the serial channel control register . When the buffer is written or read, the MSB is read or written first, then the rest of the data is read from or written to SC0BUF. Wakeup function In 9-bit UART mode, the wakeup function for slave controllers is enabled by setting SC0MOD to 1. The interrupt INTRX0 occurs only when = 1.
TXD
RXD
TXD
RXD
TXD
RXD
TXD
RXD
Master
Slave 1
Slave 2
Slave 3
Note: The TXD pins of the slave controllers must be in open-drain output mode.
Figure 3.11.24 Serial Link Using Wakeup Function
93CS40-192
2004-02-10
TMP93CS40/TMP93CS41
Protocol 1. 2. 3. Select 9-bit UART mode for the master and slave controllers. Set the SC0MOD bit of each slave controller to 1 to enable data receiving. The master controller transmits one-frame data including the 8-bit select code for the slave controllers. The MSB (bit8) is set to "1".
Start
Bit0
1
2
3
4
5
6
7
8
Stop
Select code of slave controller
"1"
4. 5.
Each slave controller receives the above frame and clears its WU bit to "0" if the above select code matches its own select code. The master controller transmits data to the specified slave controller (the one whose SC0MOD bit is cleared to "0"). The MSB (bit8) is cleared to "0".
Start
Bit0
1
2
3
4
5
6
7
Bit8
Stop
Data
"0"
6.
The other slave controllers (those with their bits remaining at 1) ignore the receiving data because their MSBs (bit8 or ) are set to "0" to disable the INTRX0 interrupt. Slave controllers (with WU = 0) can transmit data to the master controller. In this way they can indicate the end of data reception to the master controller.
93CS40-193
2004-02-10
TMP93CS40/TMP93CS41
Setting example: To link two slave controllers serially with the master controller, and use the internal clock 1 as the transfer clock.
TXD
RXD
TXD
RXD
TXD
RXD
Master
Slave 1 Select code 00000001
Slave 2 Select code 00001010
Since serial channels 0 and 1 operate in exactly the same way, channel 0 only is used for the purposes of this explanation. * Setting the master controller
Main
P9CR P9FC INTES0 SC0MOD SC0BUF
X X 1 1 0
X X 1 0 0
- -
0 1 0
-
X 0 0 0
- -
1 1 0
-
X 1 1 0
0 X 0 1 0
1 1 1 0 1
Select P90 as TXD0 pin and P91 as RXD0 pin. Enable INTTX0 and set interrupt level 4. Enable INTRX0 and set interrupt level 5. Set 1 as the transmission clock in 9-bit UART mode. Set the select code for slave controller 1.
INTTX0 interrupt
SC0MOD SC0BUF
0 *
- *
- *
- *
- *
- *
- *
- *
Sets TB8 to 0. Set data for transmission.
*
Setting the slave controller
Main
P9CR P9FC ODE INTES0 SC0MOD

X X X 1 0
X X X 1 0
- - X 0 1
- X X 1 1
- - X 1 1
-
X X 1 1
0 X
1 1 1 0 0
Select P91 as RXD0 pin and P90 as TXD0 pin (Open-drain output). Enable INTRX0 and INTTX0. Set to 1 in 9-bit UART transmission mode with transfer clock 1.
- 1 1
INTRX0 interrupt
Acc SC0BUF if Acc = Select code Then SC0MOD
-
-
-
0
-
-
--
Clear to 0.
93CS40-194
2004-02-10
TMP93CS40/TMP93CS41
3.12 Analog/Digital Converter
The TMP93CS40/S41 contains an analog/digital converter (AD converter) with 8-channel analog input that features 10-bit successive approximation. Figure 3.12.1 shows the block diagram for the AD converter. 8-channel analog input pins (AN7 to AN0) are shared by the input only port P5 which can also be used as a general-purpose input port.
Internal data bus
AD converter mode register (ADMOD1 to ADMOD2)
ADCH<2:0>
VREFON
EOCF ADBF REPET SCAN SPEED Repeat Scan End Busy Speed
ADS Start
Decoder
Analog input AN7 AN6 AN5 AN4 AN3 AN2 AN1 AN0
Channel select
AD converter control circuit
INTAD interrupt
+
Multiplexer
AD conversion result register (ADREG04 to ADREG37)
-
VREFH DA converter VREFL
Figure 3.12.1 Block Diagram for AD Converter Note 1: This AD converter does not have a built-in sample and hold circuit. Note 2: When the power supply current is reduced in IDLE2, IDLE1 or STOP mode, stop operation of the AD converter before the HALT instruction is executed. And set ADMOD2 = "00". Note 3: The operation of the AD converter is guaranteed only when fc (The high-frequency oscillator) is used (It is not guaranteed when fs is used). It is guaranteed when fFPH 4 MHz.
93CS40-195
2004-02-10
TMP93CS40/TMP93CS41
7
ADMOD1 (005EH) Bit symbol Read/Write After reset Function 0 EOCF R
6
ADBF
5
REPET R/W
4
SCAN
3
2
ADS R/W
1
0
0
0
0
0
AD
AD
Repeat mode 0: Single mode 1: Repeat mode
Scan mode 0: Fixed channel mode 1: Channel scan mode
AD conversion start 1: START Note: Always "0" is read.
conversion conversion END flag BUSY flag 1: End 1: Busy
AD conversion start
0 1
-
Start conversion Note: Always "0" when data is read
AD scan mode 0 Fixed channel mode
1 Channel scan mode AD repeat mode 0 1 0 Single mode Repeat mode Not busy
AD BUSY flag 1 Busy AD END flag 0 1 Not end End
Figure 3.12.2 AD Control Register (1/2)
93CS40-196
2004-02-10
TMP93CS40/TMP93CS41
7
ADMOD2 (005FH)
6
5
SPEED1 R/W 0
4
SPEED0
3
2
ADCH2
1
ADCH1 R/W
0
ADCH0
Bit symbol Read/Write After reset Function
VREFON R/W 1
0
0
0
0
String resistance ON/OFF
Conversion speed 00: 160 states 01: 320 states 10: 640 states 11: 1280 states
Analog input channel selection
Analog input channel selection

0 AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 AN0 AN0 AN1
1
000 001 010 011 100 101 110 111
AN0 AN1 AN2 AN0 AN1 AN2 AN3 AN4 AN4 AN5 AN4 AN5 AN6 AN4 AN5 AN6 AN7
Conversion speed 00 01 10 11 160 states (16 s at 20 MHz) 320 states (32 s at 20 MHz) 640 states (64 s at 20 MHz) 1280 states (128 s at 20 MHz)
String resistance ON/OFF selection 0 1 String resistance OFF String resistance ON
Note: Set the register to "1" before starting conversion (setting to "1").
Figure 3.12.3 AD Control Register (2/2)
93CS40-197
2004-02-10
TMP93CS40/TMP93CS41
7
ADREG04L (0060H) Bit symbol Read/Write After reset Function ADR01 R
6
ADR00
5
4
3
2
1
0
Undefined Lower 2 bits of AD result for AN0 or AN4 are stored.
7
ADREG04H (0061H) Bit symbol Read/Write After reset Function ADR09
6
ADR08
5
ADR07
4
ADR06 R
3
ADR05
2
ADR04
1
ADR03
0
ADR02
Undefined Upper 8 bits of AD result for AN0 or AN4 are stored.
7
ADREG15L (0062H) Bit symbol Read/Write After reset Function ADR11 R
6
ADR10
5
4
3
2
1
0
Undefined Lower 2 bits of AD result for AN1 or AN5 are stored.
7
ADREG15H (0063H) Bit symbol Read/Write After reset Function ADR19
6
ADR18
5
ADR17
4
ADR16 R
3
ADR15
2
ADR14
1
ADR13
0
ADR12
Undefined Upper 8 bits of AD result for AN1 or AN5 are stored.
Note: The result registers are used both as AN0 and AN4, AN1 and AN5, AN2 and AN6, and AN3 and AN7. They are stored in ADREG04, 15, 26, and 37.
MSB 9 Converted data for channel X ADREGXH 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1
LSB 0
ADREGXL 7 6 5 4 3 2 1 0
This is 1 when the register is read.
Figure 3.12.4 AD Conversion Result Register (ADREG04, ADREG15) (1/2)
93CS40-198
2004-02-10
TMP93CS40/TMP93CS41
7
ADREG26L (0064H) Bit symbol Read/Write After reset Function ADR21 R
6
ADR20
5
4
3
2
1
0
Undefined Lower 2 bits of AD result for AN2 or AN6 are stored.
7
ADREG26H (0065H) Bit symbol Read/Write After reset Function ADR29
6
ADR28
5
ADR27
4
ADR26 R
3
ADR25
2
ADR24
1
ADR23
0
ADR22
Undefined Upper 8 bits of AD result for AN2 or AN6 are stored.
7
ADREG37L (0066H) Bit symbol Read/Write After reset Function ADR31 R
6
ADR30
5
4
3
2
1
0
Undefined Lower 2 bits of AD result for AN3 or AN7 are stored.
7
ADREG37H (0067H) Bit symbol Read/Write After reset Function ADR39
6
ADR38
5
ADR37
4
ADR36 R
3
ADR35
2
ADR34
1
ADR33
0
ADR32
Undefined Upper 8 bits of AD result for AN3 or AN7 are stored.
MSB 9 Converted data for channel X ADREGXH 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1
LSB 0
ADREGXL 7 6 5 4 3 2 1 0
This is 1 when the register is read.
Figure 3.12.5 AD Conversion Result Register (ADREG26, ADREG37) (2/2)
93CS40-199
2004-02-10
TMP93CS40/TMP93CS41 3.12.1 Operation
(1) Analog reference voltage The high analog reference voltage is applied to the VREFH pin, and the low analog reference voltage is applied to the VREFL pin. The reference voltage between VREFH and VREFL is divided by 1024 (using string resistance) and compared with the analog input voltage for AD conversion. The switch between VREFH and VREFL can be turned off by writing "0" to ADMOD2. When = "0", before the conversion can start, must be written to and a 3 s period must be allowed so that the internal reference voltage can stabilize (regardless of fc) before "1" is written to ADMOD1. (2) Analog input channels The analog input channel is selected by ADMOD2. However, the channel which should be selected depends on the operation mode of the AD converter. In fixed analog input mode, one channel is selected out of eight pins, AN0 to AN7, by . In analog input channel scan mode, the number of channels to be scanned is specified by ADMOD2. For example, AN0 only, AN0 AN1, AN0 AN1 AN2, AN0 AN1 AN2 AN3, AN4 only, AN4 AN5, AN4 AN5 AN6, or AN4 AN5 AN6 AN7. When reset the AD conversion channel register will ADMOD2 = "000", so that the AN0 pin is selected. be initialized to
The pins which are not used as analog input channels can be used as ordinary input port pins for port P5. (3) Starting AD conversion AD conversion starts when "1" is written to the AD conversion register ADMOD1. When conversion starts, the conversion busy flag ADMOD1, which indicates that conversion is in progress, is set to "1". (4) AD conversion mode Both fixed AD conversion channel mode and conversion channel scan mode include two conversion modes; single and repeat conversion mode. In fixed channel repeat mode, conversion of the specified single channel is executed repeatedly. In scan repeat mode, scanning is executed repeatedly. The AD conversion mode is selected by ADMOD1. (5) AD conversion speed selection There are four AD conversion speed modes. The selection is made by the ADMOD2 register. When reset, is initialized to "00", selecting 160-state conversion mode (16 s at 20 MHz).
93CS40-200
2004-02-10
TMP93CS40/TMP93CS41
(6) AD conversion end and interrupt * AD conversion single mode When AD conversion of the specified channel has finished (in fixed channel conversion mode) or when AD conversion of the last channel has finished (in channel scan mode), ADMOD is set to "1", the ADMOD flag is reset to "0", and the INTAD interrupt is generated. * AD conversion repeat mode For both fixed conversion channel mode and conversion channel scan mode, INTAD should be disabled in repeat mode. Always set INTE0AD to "000", to disable the interrupt request. Write 0 to ADMOD2 to terminate repeat mode. Repeat mode will be exited as soon as the conversion in progress is completed. (7) Storing the AD conversion result The results of AD conversion are stored in the registers ADREG04, ADREG15, ADREG26, ADREG37 for each channel. The result registers are used as AN0 and AN4, AN1 and AN5, AN2 and AN6, and AN3 and AN7. However, the contents of the registers do not indicate which channel's data has been converted. In repeat mode, the registers are updated as soon as conversion ends. ADREG04 to ADREG37 are read only registers. (8) Reading the AD conversion result The results of AD conversion are stored in the registers ADREG04 to ADREG37. When the lowest two bits of one of the registers ADREG04L, ADREG15L, ADREG26L, or ADREG37L are read, ADMOD1 is cleared to "0". is not cleared to "0" when the upper eight bits of one of the registers ADREG04H, ADREG15H, ADREG26H, or ADREG37H are read.
93CS40-201
2004-02-10
TMP93CS40/TMP93CS41
Setting example: 1. When the analog input voltage on the AN3 pin is AD converted at 160-state speed and the result is transferred to the memory address 0100H by the AD interrupt INTAD routine.
Main setting
INTE0AD ADMOD2 ADMOD1
1 1 X
1 X X
0 0 0
0 0 0
- X X
-
0 1
-
1 X
-
1 X
Enable INTAD and set interrupt level 4. Specify AN3 pin as an analog input channel and start AD conversion in 160-state speed mode.
INTAD routine
WA WA (000100H)
ADREG37
>> 6 WA
Read ADREG37L and ADREG37H values and write to WA (16 bits). Right-shift WA six times and write "0" in upper bits. Write contents of WA in memory at 0100H.
2.
When the analog input voltage of the four pins AN4 to AN7 are AD converted at 320-state speed and the channel is set to scan and repeat mode.
Main setting
INTE0AD ADMOD2 ADMOD1
1 1 X
0 X X
0 0 1
0 1 1
-
0 X
-
1 1
-
1 0
-
1 0
Disable INTAD. Specify AN4 to AN7 pins as input channel, select scan and repeat mode and start AD conversion.
X: Don't care, -: No change
93CS40-202
2004-02-10
TMP93CS40/TMP93CS41
3.13 Watchdog Timer (Runaway Detection Timer) and Warm-up Timer
The TMP93CS40/S41 contains a watchdog timer for runaway detection. The watchdog timer (WDT) is used to return the CPU to a normal state when it detects that the CPU has started to malfunction (runaway) due to causes such as noise. When the watchdog timer detects a malfunction, it generates a non-maskable interrupt to notify the CPU of the malfunction, and outputs "0" from the watchdog timer out pin WDTOUT to notify peripheral devices of the malfunction. Connecting the watchdog timer output to the reset pin internally forces a reset. The watchdog timer consists of 7-stage and 15-stage binary counters. These binary counters are also used as a warm-up timer for internal oscillator stabilization. This is used for releasing stop and also before changing the system clock.
3.13.1
Configuration
Figure 3.13.1 shows the block diagram for the watchdog timer (WDT).
RESET
Internal reset
WDMOD
WDTOUT
SYSCR0 Enable
WDTOUT ,
WDTI interrupt Reset WDMOD Write disable code to WDCR (B1H)
Q
S R
interrupt control
WDMOD T45CR
Selector
Selector
WDMOD
27
29 211 213 215
Selector
Selector
Selector
7-stage binary counter
15-stage binary counter SYSCR0 Reset Reset
Write clear code to WDCR (4EH)
2
Selection of WDT and warm-up clock
HALT instruction (STOP, IDLE1 mode)
fc/fs changing warm-up clock fs XT1
Selector
CPU 2
Selector
SYSCR1
fc fc/2 fc/4 fc/8 fc/16
SYSCR1 X1
/2 /4 /8 /16
Figure 3.13.1 Block Diagram for Watchdog Timer/Warm-up Timer
93CS40-203
2004-02-10
TMP93CS40/TMP93CS41
The watchdog timer consists of 7-stage and 15-stage binary counters which use the system clock (fSYS) as the input clock. The 15-stage binary counter has fSYS/215, fSYS/217, fSYS/219 and fSYS/221 outputs. Selecting one of the outputs with the WDMOD register generates a watchdog interrupt and outputs watchdog timer out when an overflow occurs. For the warm-up counter, either a 27 or a 29 output from the 15-stage binary counter can be selected using the WDMOD register. When a stable-external oscillator is used, a shorter warm-up time is available using the T45CR register. When = "1", a counting value 27 is selected. When the watchdog timer is in operation, this shorter warm-up time function cannot be selected. The warm-up counter function can be made available by setting = "0". Since the watchdog timer out pin ( WDTOUT ) outputs "0" when there is a watchdog timer overflow, the peripheral devices can be reset. The watchdog timer out pin is set to "1" after WDT has been disabled and the watchdog timer cleared (by a clear code 4EH being written into the WDCR register). Example: LDW (WDMOD), B100H LD SET (WDCR), 4EH 7, (WDMOD) ; Disable ; Write clear code ; Enable again
In other words, WDTOUT keeps outputting "0" until the clear code is written. The watchdog timer out pin can also be connected to the reset pin internally. In this case, the watchdog timer out pin ( WDTOUT ) outputs "0" for 8 to 20 states (12.8 to 32 s at fc = 20 MHz), and then resets itself.
WDT counter WDT interrupt
n
Overflow
0
Write clear code WDT clear (Software)
WDTOUT
Figure 3.13.2 Normal Mode
Overflow WDT counter WDT interrupt
WDTOUT
n
(Internal reset) 8 to 20 states = 12.8 to 32 s (at 20 MHz)
Figure 3.13.3 Reset Mode
93CS40-204
2004-02-10
TMP93CS40/TMP93CS41 3.13.2 Control Registers
The watchdog timer WDT is controlled by two control registers WDMOD and WDCR. (1) Watchdog timer mode register (WDMOD) 1. Setting the detection time for the watchdog timer This 2-bit register is used to set the watchdog timer interrupt time for detecting runaway. This register is initialized to WDMOD = "00" when reset. The detection time for WDT is shown in Figure 3.13.6. 2. Watchdog timer enable/disable control When reset, WDMOD is initialized to "1" to enable the watchdog timer. To disable the timer, it is necessary to clear this bit to "0" and write the disable code (B1H) into the watchdog timer control register WDCR. This makes it difficult for the watchdog timer to be disabled by runaway. However, it is possible to return from the disabled state to the enabled state simply by setting to "1". 3. Watchdog timer out reset connection This bit is used to connect the output of the watchdog timer with RESET internally. Since WDMOD is initialized to "0" at reset, a watchdog timer reset is not performed. (2) Watchdog timer control register (WDCR) This register is used to disable and clear the watchdog timer's binary counter. * Disable control The watchdog timer can be disabled by writing the disable code (B1H) to the WDCR register after clearing WDMOD to "0".
WDMOD WDCR
0 1
-
0
-
1
-
1
-
0
-
0
X 0
X 1
Clear WDMOD to "0". Write the disable code (B1H).
* *
Enable control This sets WDMOD to "1". Watchdog timer clear control
The binary counter can be cleared and made to resume counting by writing the clear code (4EH) into the WDCR register.
WDCR
0
1
0
0
1
1
1
0
Write the clear code (4EH).
93CS40-205
2004-02-10
TMP93CS40/TMP93CS41
7
WDMOD (005CH) Bit symbol Read/Write After reset Function 1 WDTE
6
WDTP1
5
WDTP0
4
WARM R/W
3
HALTM1
2
HALTM0
1
RESCR
0
DRVE
0
0
0
0
0
0
0
WDT control 1: Enable
Select detection time 00: 215/fSYS 01: 217/fSYS 10: 219/fSYS 11: 221/fSYS See Figure 3.13.6
Warm-up time
Standby mode 00: RUN mode 01: STOP mode 10: IDLE1 mode 11: IDLE2 mode
1: Internally connects WDT out to the reset pin
1: Drives the pin even in STOP mode
DRVE (Explanation in STOP mode section) Watchdog timer out control 0 1
-
Connects WDT out to reset
Select the standby mode HALT instruction 00 01 10 11 Selection of warm-up time RUN mode (only the CPU stops) STOP mode (All circuits stop) IDLE1 mode (only the oscillator operates) IDLE2 mode (CPU and AD stop) at fc = 20 MHz, fs = 32.768 kHz
System Clock Selection
1 (fs)
Warm-up Time Gear Value
XXX (Don't care) 000 (fc) 001 (fc/2)
T45CR = 0 WARM = 0 WARM = 1
0.50 s 0.82 ms 1.64 ms 3.28 ms 6.55 ms 13.11 ms 2.00 s 3.28 ms 6.55 ms 13.11 ms 26.21 ms 52.43 ms
T45CR = 1 WARM = X
3.9 ms 6.4 s 12.8 s 25.6 s 51.2 s 102.4 s
0 (fc)
010 (fc/4) 011 (fc/8) 100 (fc/16)
Watchdog timer enable/disable control 0 1 Disable Enable
Figure 3.13.4 Watchdog Timer Mode Register
93CS40-206
2004-02-10
TMP93CS40/TMP93CS41
7
WDCR (005DH) Bit symbol Read/Write After reset Function
6
5
4
-
W
3
2
1
0
-
B1H: WDT disable code 4EH: WDT clear code
Disable/clear WDT B1H 4EH Others Disable code Clear code Don't set
Figure 3.13.5 Watchdog Timer Control Register
at fc = 20 MHz, fs = 32.768 kHz
System Clock Selection
1 (fs)
Watchdog Timer Detecting Time Gear Value 00
XXX (Don't care) 000 (fc) 001 (fc/2) 2.00 s 3.28 ms 6.55 ms 13.11 ms 26.21 ms 52.43 ms
WDMOD 01
8.00 s 13.11 ms 26.24 ms 52.43 ms 104.86 ms 209.72 ms
10
32.00 s 52.43 ms 104.86 ms 209.72 ms 419.43 ms 838.86 ms
11
128.0 s 209.72 ms 419.43 ms 838.86 ms 1.68 s 3.36 s
0 (fc)
010 (fc/4) 011 (fc/8) 100 (fc/16)
Note: When using the register as the watchdog timer, write 0 to the T45CR bit.
Figure 3.13.6 Watchdog Timer Detection Time
93CS40-207
2004-02-10
TMP93CS40/TMP93CS41 3.13.3 Operation
The watchdog timer generates interrupt INTWD after the detection time set in the WDMOD and T45CR registers has elapsed, and outputs a low level signal. The watchdog timer must be cleared to zero by software before an INTWD interrupt is generated. If the CPU malfunctions (Undergoes runaway) due to causes such as noise, but does not execute the instruction used to clear the binary counter, the binary counter overflows and an INTWD interrupt is generated. The CPU detects malfunction (Runaway) from the INTWD interrupt and it is possible to return to normal operation using a recovery program. If the watchdog timer out pin is connected to the reset pins of peripheral devices, a CPU malfunction can also be acknowledged by these other devices. The watchdog timer restarts operation immediately after reset is released. The watchdog timer does not operate in IDLE1 or STOP mode. In RUN mode, the watchdog timer is operational. When the bus is released ( BUSAK = L), WDT continues counting. However, the function can be disabled when entering RUN or IDLE2 mode. The watchdog timer is enabled in IDLE2 mode, but the overflow interrupt is disabled. Disable the watchdog timer before entering IDLE2 mode. Example: 1. Clear the binary counter.
WDCR
0
1
0
0
1
1
1
0
Write the clear code (4EH).
2. Set the watchdog timer detecting time to 218/fSYS.
WDMOD
1
0
1
-
-
-
X
X
3. Disable the watchdog timer.
WDMOD WDCR
0 1
-
0
-
1
-
1
-
0
-
0
X 0
X 1
Clear WDTE to "0". Write disable code (B1H).
4. Set IDLE1 mode.
0 - - 1 0 1 Executes halt command
WDMOD
-
1
1 0
0 0
X 0
X 1
Disable WDT and set IDLE1 mode. Set standby mode.
WDCR
5. Set the STOP mode (Warm-up time: 216/fSYS)
WDMOD
-
-
-
1
0
1
X
X
Set the STOP mode. Execute HALT instruction. Set standby mode.
Executes halt command
93CS40-208
2004-02-10
TMP93CS40/TMP93CS41
4.
4.1
Electrical Characteristics
Maximum Ratings
TMP93CS40F, TMP93CS41F TMP93CS40DF, TMP93CS41DF Parameter
Power supply voltage Input voltage Output current (Total) Output current (Total) Power dissipation (Ta = 85C) Soldering temperature (10 s) Storage temperature Operating temperature
"X" used in an expression shows a frequency for the clock fFPH selected by SYSCR1. The value of X changes according to whether a clock gear or a low speed oscillator is selected. An example value is calculated for fc, with gear = 1/fc (SYSCR1 = 0000).
Symbol
VCC VIN IOL IOH PD TSOLDER TSTG TOPR
Rating
-0.5 to 6.5 -0.5 to VCC + 0.5 120 -80 600 260 -65 to 150 -40 to 85
Unit
V V mA mA mW C C C
Note: The maximum ratings are rated values which must not be exceeded during operation, even for an instant. Any one of the ratings must not be exceeded. If any maximum rating is exceeded, a device may break down or its performance may be degraded, causing it to catch fire or explode resulting in injury to the user. Thus, when designing products which include this device, ensure that no maximum rating value will ever be exceeded.
4.2
DC Characteristics (1/2)
Ta = -40 to 85C
Parameter
Power supply voltage AVCC = VCC AVCC = VSS = 0 V
Symbol
Condition
fc = 4 to 20 MHz fs = 30 to 34 kHz
Min
4.5
Typ. (Note)
Max
Unit
VCC fc = 4 to 12.5 MHz VIL VIL1 VIL2 VIL3 VIL4 VIH VIH1 VIH2 VIH3 VIH4 VOL VOH1 IOL = 1.6 mA VCC = 2.7 to 5.5 V VCC 4.5 V VCC < 4.5 V VCC = 2.7 to 5.5 V VCC 4.5 V VCC < 4.5 V
5.5 2.7 0.8 0.6 -0.3 0.3 VCC 0.25 VCC 0.3 0.2 VCC 2.2 2.0 0.7 VCC 0.75 VCC VCC - 0.3 0.8 VCC VCC + 0.3
V
AD0 to AD15 Input low voltage Port 2 to port A (except P87)
RESET , NMI , INT0
EA , AM8/ AM16
X1 AD0 to AD15
V
Input high voltage
Port 2 to port A (except P87)
RESET , NMI , INT0
EA , AM8/ AM16
X1
Output low voltage
(VCC = 2.7 to 5.5 V) IOH = -400 A (VCC = 3 V 10%) IOH = -400 A (VCC = 5 V 10%) 2.4 4.2
0.45 V
Output high voltage VOH2
Note:
Typical values are for Ta = 25C and VCC = 5 V unless otherwise noted.
93CS40-209
2004-02-10
TMP93CS40/TMP93CS41
4.2 DC Characteristics (2/2)
Parameter
Darlington drive current (8 output pins max) Input leakage current Output leakage current Powerdown voltage (at stop, RAM backup)
RESET pull-up resistor
Symbol
IDAR (Note 2) ILI ILO VSTOP RRST CIO VTH RKL RKH ICC
Condition
VEXT = 1.5 V REXT = 1.1 k (when VCC = 5 V 10%) 0.0 VIN VCC 0.2 VIN VCC - 0.2 V IL2 = 0.2 VCC, V IH2 = 0.8 VCC VCC = 5 V 10% VCC = 3 V 10% fc = 1 MHz
Min
-1.0
Typ. (Note 1)
Max
-3.5
Unit
mA
0.02 0.05 2.0 50 80
5 10 6.0 150 200 10
A V k pF V
Pin capacitance Schmitt width RESET , NMI , INT0 Programmable pull-down resistor Programmable pull-up resistor NORMAL (Note 3) NORMAL2 (Note 4) RUN IDLE2 IDLE1 NORMAL (Note 3) NORMAL2 (Note 4) RUN IDLE2 IDLE1 SLOW (Note 3) RUN IDLE2 IDLE1 STOP
0.4 VCC = 5 V 10% VCC = 3 V 10% VCC = 5 V 10% VCC = 3 V 10% VCC = 5 V 10% fc = 20 MHz 10 30 50 100
1.0 80 150 150 300 19 24 17 10 3.5 25 30 25 15 5 10 13 9 5 1.5 35 30 20 15 10
k
mA
VCC = 3 V 10% fc = 12.5 MHz (Typ: VCC = 3.0 V)
6.5 9.5 5.0 3.0 0.8
mA
VCC = 3 V 10% fs = 32.768 kHz (Typ: Vcc = 3.0 V) VCC = 2.7 to 5.5 V
20 16 10 5 0.2
A
A
Note 1: Typical values are for Ta = 25C and VCC = 5 V unless otherwise noted. Note 2: IDAR is guaranteed for up to eight ports. Note 3: ICC measurement conditions (NORMAL, SLOW): Only CPU is operational; output pins are open and input pins are fixed. Note 4: ICC measurement conditions (NORMAL2): All functions are operational; output pins are open and input pins are fixed.
93CS40-210
2004-02-10
TMP93CS40/TMP93CS41
4.3
AC Characteristics
(1) VCC = 5 V 10% Variable Min
50 2x - 40 0.5x - 20 1.5x - 70 0.5x - 15 0.5x - 20 x - 40 0.5x - 25 0.5x - 20 x - 25 1.5x - 50 0.5x - 25 3.0x - 55 3.5x - 65 2.0x - 60 2.0x - 40 0 x - 15 2.0x - 40 2.0x - 55 0.5x - 15 3.5x - 90 3.0x - 80 2.0x + 0 2.5x - 120 2.5x + 50 200 1.0x - 40 0.5x - 15 2.5x - 70 0.5x - 15 2.0x - 40 2.0x - 40 1.0x - 40 0.5x - 25 1.0x - 40 1.5x - 65 1.5x - 30 64 16 85 85 23 6 23 29 40 23 16 86 10 60 60 10 0 10 10 206 200 10 10 55 125 36 175 200 85 0 48 85 70 16 129 108 100 5
No.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
Parameter
Osc. period (= X) CLK pulse width A0 to A23 valid CLK hold CLK valid A0 to A23 hold A0 to A15 valid ALE fall ALE fall A0 to A15 hold ALE high pulse width ALE fall RD / WR fall
RD / WR rise ALE rise
Symbol
tOSC tCLK tAK tKA tAL tLA tLL tLC tCL tACL tACH tCA tADL tADH tRD tRR tHR tRAE tWW tDW
(1 + N) WAIT mode (1 + N) WAIT mode (1 + N) WAIT mode
16 MHz Min
62.5 85 11 24 16 11 23 6 11 38 44 6 133 154 65
20 MHz Min
50 60 5 5 10 5 10 0 5 25 25 0 95 110 40 60 0 35 60 45 10 85 70
Max
31250
Max
Max
Unit
ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns
A0 to A15 valid RD / WR fall A0 to A23 valid RD / WR fall
RD / WR rise A0 to A23 hold
A0 to A15 valid D0 to D15 input A0 to A23 valid D0 to D15 input
RD fall D0 to D15 input
RD low pulse width RD rise D0 to D15 hold
RD rise A0 to A15 output WR low pulse width
D0 to D15 valid WR rise
WR rise D0 to D15 hold
tWD tAWH tAWL tCW tAPH tAPH2 tCP tASRH tASRL tRAC tRAH tRAS tRP tRSH tRSC tRCD tCAC tCAS
A0 to A23 valid WAIT input A0 to A15 valid WAIT input
RD / WR fall WAIT hold
A0 to A23 valid Port input A0 to A23 valid Port hold
WR rise Port valid
A0 to A23 valid RAS fall A0 to A15 valid RAS fall
RAS fall D0 to D15 input RAS fall A0 to A15 hold RAS low pulse width RAS high pulse width CAS fall RAS rise RAS rise CAS rise RAS fall CAS fall CAS fall D0 to D15 input CAS low pulse width
AC measuring conditions * Output level: High 2.2 V/Low 0.8 V, CL = 50 pF (However, CL = 100 pF for AD0 to AD15, A0 to A23, ALE, RD , WR , HWR , R/ W , CLK, RAS , CAS0 to CAS2 ) * Input level: High 2.4 V/Low 0.45 V (AD0 to AD15) High 0.8 x VCC/Low 0.2 x VCC (except for AD0 to AD15)
93CS40-211
2004-02-10
TMP93CS40/TMP93CS41
(2) VCC = 3 V 10% Variable Min
80 2x - 40 0.5x - 30 1.5x - 80 0.5x - 35 0.5x - 35 x - 60 0.5x - 35 0.5x - 40 x - 50 1.5x - 50 0.5x - 40 3.0x - 110 3.5x - 125 2.0x - 115 2.0x - 40 0 x - 25 2.0x - 40 2.0x - 120 0.5x - 40 3.5x - 130 3.0x - 100 2.0x + 0 2.5x - 195 2.5x + 50 200 1.0x - 60 0.5x - 40 2.5x - 90 0.5x - 25 2.0x - 40 2.0x - 40 1.0x - 55 0.5x - 25 1.0x - 40 1.5x - 120 1.5x - 40 80 15 120 120 25 15 40 0 20 0 110 250 200 160 5 120 0 55 120 40 0 150 140
No.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
Parameter
Osc. period (= X) CLK pulse width A0 to A23 valid CLK hold CLK valid A0 to A23 hold A0 to A15 valid ALE fall ALE fall A0 to A15 hold ALE high pulse width ALE fall RD / WR fall
RD / WR rise ALE rise
Symbol
tOSC tCLK tAK tKA tAL tLA tLL tLC tCL tACL tACH tCA tADL tADH tRD tRR tHR tRAE tWW tDW
(1 + N) WAIT mode (1 + N) WAIT mode (1 + N) WAIT mode
12.5 MHz Min
80 120 10 40 5 5 20 5 0 30 70 0 130 155 45
Max
31250
Max
Unit
ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns
A0 to A15 valid RD / WR fall A0 to A23 valid RD / WR fall
RD / WR rise A0 to A23 hold
A0 to A15 valid D0 to D15 input A0 to A23 valid D0 to D15 input
RD fall D0 to D15 input
RD low pulse width RD rise D0 to D15 hold
RD rise A0 to A15 output WR low pulse width
D0 to D15 valid WR rise
WR rise D0 to D15 hold
tWD tAWH tAWL tCW tAPH tAPH2 tCP tASRH tASRL tRAC tRAH tRAS tRP tRSH tRSC tRCD tCAC tCAS
A0 to A23 valid WAIT input A0 to A15 valid WAIT input
RD / WR fall WAIT hold
A0 to A23 valid Port input A0 to A23 valid Port hold
WR rise Port valid
A0 to A23 valid RAS fall A0 to A15 valid RAS fall
RAS fall D0 to D15 input RAS fall A0 to A15 hold RAS low pulse width RAS high pulse width CAS fall RAS rise RAS rise CAS rise RAS fall CAS fall CAS fall D0 to D15 input CAS low pulse width
AC measuring conditions * * Output level: High 0.7 x VCC/Low 0.3 x VCC, CL = 50 pF Input level: High 0.9 x VCC/Low 0.1 x VCC
93CS40-212
2004-02-10
TMP93CS40/TMP93CS41
(1) Read cycle
tOSC
X1
tCLK
CLK
tAK tKA
A0 to A23
CS0 to CS2
R/ W
tAWH tCW tAWL
WAIT
tAPH tAPH2 Port input (Note) tASRH
RAS
tRSH tRAS tRSC tRAC tCAS tCAC tCA tRR tACL tLC tRD tADL tHR
tRP
tASRL
tRAH
CAS0 to CAS2
tRCD tADH tACH
RD
tRAE
AD0 to AD15 tAL ALE tLL
A0 to A15 tLA
D0 to D15
tCL
Note:
Since the CPU accesses the internal area to read data from a port, the control signals of external pins such as RD and CS are not enabled. Therefore, the above waveform diagram should be regarded as depicting internal operation. Please also note that the timing and AC characteristics of port input/output shown above are typical representation. For details, contact your local Toshiba sales representative.
93CS40-213
2004-02-10
TMP93CS40/TMP93CS41
(2) Write cycle
X1
CLK
A0 to A23
CS0 to CS2
R/ W
WAIT
Port output (Note) tCP
RAS
CAS0 to CAS2
WR , HWR
tWW
tDW AD0 to AD15 A0 to A15 D0 to D15
tWD
ALE
Note:
Since the CPU accesses the internal area to write data to a port, the control signals of external pins such as WR and CS are not enabled. Therefore, the above waveform diagram should be regarded as depicting internal operation. Please also note that the timing and AC characteristics of port input/output shown above are typical representation. For details, contact your local Toshiba sales representative.
93CS40-214
2004-02-10
TMP93CS40/TMP93CS41
4.4
AD Conversion Characteristics
AVCC = VCC, AVSS = VSS
Parameter
Analog reference voltage (+) Analog reference voltage (-) Analog input voltage range Analog current for analog reference voltage = 1 = 0 Error (not including quantizing errors)
Symbol
VREFH VREFL VAIN
Power Supply
VCC = 5 V 10% VCC = 3 V 10% VCC = 5 V 10% VCC = 3 V 10% VCC = 5 V 10%
Min
VCC - 1.5 V VCC - 0.2 V VSS VSS VREFL
Typ
VCC VCC VSS VSS 0.5 0.3 0.02
Max
VCC VCC VSS + 0.2 V VSS + 0.2 V VREFH 1.5 0.9 5.0
Unit
V
IREF (VREFL = 0 V)
VCC = 3 V 10% VCC = 2.7 to 5.5 V VCC = 5 V 10% VCC = 3 V 10%
mA
A
LSB
-
10
1.0 1.0
3.0 3.0
Note 1: 1LSB = (VREFH - VREFL)/2 [V] Note 2: The operation of this AD converter is guaranteed only using fc (The high-frequency oscillator). It is not guaranteed for fs. The operation above is guaranteed for fFPH 4 MHz. Note 3: The value ICC includes the current which flows through the AVCC pin.
4.5
Serial Channel Timing
(1) I/O interface mode 1. SCLK input mode
Symbol Min
tSCY tOSS tOHS tHSR tSRD 16X tSCY/2 - 5X - 50 5X - 100
Parameter
SCLK cycle Output data Rising edge or falling edge* of SCLK SCLK rising edge or falling edge*
Output data hold
Variable Max
32.768 MHz (Note) 12.5 MHz Min
488 91.5 s 152 s
20 MHz
Unit
s
Max
Min Max Min Max
1.28 190 0.8 100
ns
300
150
ns
SCLK rising edge or falling edge*
Input data hold
0 tSCY - 5X - 100
0 336 s
0
0
ns
SCLK rising edge or falling edge*
Effective data input
780
450
ns
Note: *
System clock is fs, or input clock to prescaler is divisor clock of fs. The rising edge is used in SCLK rising mode. The falling edge is used SCLK falling mode. 2. SCLK output mode
Symbol Min
tSCY tOSS tOHS tHSR tSRD 16X tSCY - 2X - 150 2X - 80 0 tSCY - 2X - 150
Parameter
SCLK cycle (Programmable) Output data SCLK rising edge SCLK rising edge Output data hold SCLK rising edge Input data hold SCLK rising edge Effective data input
Variable Max
8192X
32.768 MHz (Note) Min
488 427 s 60 s 0 428 s
12.5 MHz Min
1.28 970 80 0 970
20 MHz Min Max
0.8 550 20 0 550 409.6
Unit
s
Max
250 ms
Max
655.36
ns ns ns ns
Note:
System clock is fs, or input clock to prescaler is divisor clock of fs.
93CS40-215
2004-02-10
TMP93CS40/TMP93CS41
tSCY
SCLK Output mode/ input rising mode SCLK (Input falling mode) tOSS Output data TXD 0
tOHS 1 2 3
tSRD Input data RXD 0 Valid 1 Valid
tHSR 2 Valid 3 Valid
4.6
Timer/Counter Input Clock (TI0, TI4, TI5, TI6 and TI7)
Parameter Symbol
tVCK tVCKL tVCKH
Variable Min
8X + 100 4X + 40 4X + 40
12.5 MHz Min
740 360 360
20 MHz Min
500 240 240
Max
Max
Max
Unit
ns ns ns
Clock cycle Low level clock pulse width High level clock pulse width
4.7
Interrupt and Capture
(1) NMI and INT0 interrupts Parameter Symbol
tINTAL tINTAH
Variable Min
4X 4X
12.5 MHz Min
320 320
20 MHz Min
200 200
Max
Max
Max
Unit
ns ns
NMI , INT0 low level pulse width
NMI , INT0 high level pulse width
(2) INT4 to INT7 interrupts, capture The INT4 to INT7 input pulse width depends on the CPU operation clock and timer (9-bit prescaler). The following shows the pulse width for each clock.
tINTBL (INT4 to INT7 low level pulse width) tINTBH (INT4 to INT7 high level pulse width)
System Clock Prescaler Clock Selected Selected
00 (fFPH) 0 (fc) 1 (fs) (Note 2) 01 (fs) 10 (fc/16) 00 (fFPH) 01 (fs)
Variable Min
8X + 100 8XT + 0.1 128x + 0.1 8XT + 0.1
20 MHz Min
500 244.3 6.5 244.3
Variable Min
8X + 100 8XT + 0.1 128X + 0.1 8XT + 0.1
20 MHz Min
500 244.3 6.5 244.3
Unit
ns
s
Note 1: Note 2:
XT represents the frequency of the low-frequency clock fs. Calculated at fs = 32.768 kHz. When using fs as the system clock, fc/16 cannot be selected as the prescaler clock.
93CS40-216
2004-02-10
TMP93CS40/TMP93CS41
4.8
SCOUT Pin AC Characteristics
Parameter Symbol Variable Min
0.5X - 10 tSCH 0.5X - 20 0.5X - 10 tSCL 0.5X - 20 30 30 40
12.5 MHz Min
40
20 MHz Min
15
Max
Max
Max
Unit
High-level pulse width VCC = 5 V 10% High-level pulse width VCC = 3 V 10% Low-level pulse width VCC = 5 V 10% Low-level pulse width VCC = 3 V 10%
ns
-
15
-
ns
-
-
Measurement condition * Output level: High 2.2 V/Low 0.8 V, CL = 10 pF
tSCH SCOUT tSCL
93CS40-217
2004-02-10
TMP93CS40/TMP93CS41
4.9
Timing Chart for Bus Request (BUSRQ )/Bus Acknowledge ( BUSAK )
(Note 1)
CLK
tBRC
BUSRQ
tBRC tCBAL tCBAH
BUSAK
AD0 to AD15, A0 to A23, CS0 to CS2 , R/ W , RAS , CAS0 to CAS2
tABA
tBAA (Note 2)
RD , WR , HWR
(Note 2)
ALE
Parameter
BUSRQ setup time to CLK
Symbol
tBRC tCBAL tCBAH tABA tBAA
Variable Min
120 1.5X + 120 0.5x + 40 0 0 80 80
12.5 MHz Min
120 240 80 0 0 80 80
20 MHz Min
120 195 65 0 0 80 80
Max
Max
Max
Unit
ns ns ns ns ns
CLK BUSAK falling edge CLK BUSAK rising edge Output buffer off to BUSAK
BUSAK
to output buffer on
Note 1: Even if the BUSRQ signal goes low, the bus will not be released while the WAIT signal is low. The bus will only be released when BUSRQ goes low while WAIT is high. Note 2: This line shows only that the output buffer is in the off state. It does not indicate that the signal level is fixed. Just after the bus is released, the signal level set before the bus was released is maintained dynamically by the external capacitance. Therefore, to fix the signal level using an external resistor during bus release, careful design is necessary, as fixing of the level is delayed. The internal programmable pull-up/pull-down resistor is switched between the active and non-active states by the internal signal.
93CS40-218
2004-02-10
TMP93CS40/TMP93CS41
4.10 Recommended Oscillator
The TMP93CS40/S41 are evaluated with various resonators. The evaluation results are displayed below to enable appropriate selection for any given application. Note: The load capacitance of the resonator consists of the load capacitors C1 and C2 which are to be connected and the floating capacitance of the target board. Even if the specified values of C1 and C2 are used, there is a possibility that the oscillator will malfunction due to varying load capacitance on the target boards. Hence the oscillator's wiring patterns on the board should be designed to be as short as possible. It is recommended that evaluation of the resonators be conducted on the target board.
(1) Examples of resonator connection
X1 X2 XT1 XT2 Rd
Rd
C1
C2
C1
C2
Figure1: Example of High-frequency Resonator Connection
Figure2: Example of Low-frequency Resonator Connection
(2) Ceramic resonator: Murata Manufacturing. Co., Ltd (Note 1)
Ta = -20 to 80C
Parameter
Frequency (MHz)
4.00 10.00
Recommended Resonator
CSA4.00MG CST4.00MGW CSA10.0MTZ093 CST10.0MTW093 CSA12.5MTZ093 CST12.5MTW093 CSA16.00MXZ040 CST16.00MXW0C1 CSA20.00MXZ040
Recommended Value C1 [pF]
30 (30) (Note 2) 30 (30) (Note 2) 30 (30) (Note 2) 5 (5) (Note 2) 3
C2 [pF]
30 (30) (Note 2) 30 (30) (Note 2) 30 (30) (Note 2) 5 (5) (Note 2) 3
Rd [k]
VCC [V]
2.7 to 5.5 0
High-frequency oscillation 12.50 16.00 20.00
4.5 to 5.5
Note 1: Murata Manufacturing. Co., Ltd. (Japan) The product numbers and specifications of the resonators by Murata Manufacturing Co., Ltd. are subject to change. For up-to-date information, please refer to the following URL: http://www.murata.com/ Note 2: For built-in condenser type
93CS40-219
2004-02-10
TMP93CS40/TMP93CS41
(3) Crystal resonator: Nihon Denpa Kogyo (Note 1)
Ta = -10 to 60C
Parameter
Frequency (MHz)
4.00 10.00 12.50 16.00 20.00
Recommended Resonator
NT040016A NT100016A NT125016A NT160016A NT200016A
Recommended Value C1 [pF]
12 10 10 10 7
C2 [pF]
12 10 10 10 7
Rd [k]
Vcc [V]
High-frequency oscillation
2.7 to 5.5 0 4.5 to 5.5 Fax: +1-510-623-6590 Fax: +65-6293-1150 Fax: +852-2956-1567 Fax: +44-20-8390-6926 Fax: +33-1-60-95-8200 Fax: +39-02-96703284
Note 1: NDK AMERICA, INC.: U.S.A NDK ELECTRONICS SINGAPORE PTE, LTD. NDK EUROPE LIMITED: ENGLAND NDK FRANCE SARL: FRANCE NDK ITALY SRL: ITALY Note 2: High-frequency resonator NR-18: AT-51: CP12A:
Phone: +1-510-623-6512, Phone: +65-6298-9878, Phone: +44-20-8390-8344, Phone: +33-1-60-95-0000, Phone: +39-02-96702920, Lead mount type Lead mount type Surface mount type
NDK ELECTRONICS (HK) LIMITED: HONG KONG Phone: +852-2956-3181,
93CS40-220
2004-02-10
TMP93CS40/TMP93CS41
5.
Table of Special Function Registers (SFRs)
(SFR: Special function register) The special function registers (SFRs) include the I/O ports and peripheral control registers allocated to the 128 bytes whose addresses run from 000000H to 00007FH. (1) I/O ports (2) I/O port control (3) Timer control (4) Pattern generator control (5) Watchdog timer control (6) Serial channel control (7) AD converter control (8) Interrupt control (9) Chip select/wait control (10) Clock control Configuration of the table
Symbol Name Address 7 6 1 0 Bit symbol Read/Write Initial value after reset Remarks
Note: "Prohibit RMW" in the table means that you cannot use RMW instructions on these registers. (Example) When setting only bit0 of register P0CR, "SET 0, (0002H)" cannot be used. The LD (Transfer) instruction must be used to write all eight bits.
93CS40-221
2004-02-10
TMP93CS40/TMP93CS41
Table 5.1 I/O Register Address Map Address
000000H 1H 2H 3H 4H 5H 6H 7H 8H 9H AH BH CH DH EH FH 10H 11H 12H 13H 14H 15H 16H 17H 18H 19H 1AH 1BH 1CH 1DH 1EH 1FH
Name
P0 P1 P0CR P1CR P1FC P2 P3 P2CR P2FC P3CR P3FC P4 P5 P4CR P4FC P6 P7 P6CR P7CR P6FC P7FC P8 P9 P8CR P9CR P8FC P9FC PA PACR
Address
20H 21H 22H 23H 24H 25H 26H 27H 28H 29H 2AH 2BH 2CH 2DH 2EH 2FH 30H 31H 32H 33H 34H 35H 36H 37H 38H 39H 3AH 3BH 3CH 3DH 3EH 3FH
Name
TRUN TREG0 TREG1 TMOD TFFCR TREG2 TREG3 P0MOD P1MOD PFFCR
Address
40H 41H 42H 43H 44H 45H 46H 47H 48H 49H 4AH 4BH 4CH 4DH 4EH 4FH 50H 51H 52H 53H 54H 55H 56H 57H 58H 59H 5AH 5BH 5CH 5DH 5EH 5FH
Name
TREG6L TREG6H TREG7L TREG7H CAP3L CAP3H CAP4L CAP4H T5MOD T5FFCR
Address
60H 61H 62H 63H 64H 65H 66H 67H 68H 69H 6AH 6BH 6CH 6DH 6EH 6FH 70H 71H 72H 73H 74H 75H 76H 77H 78H 79H 7AH 7BH 7CH 7DH 7EH 7FH
Name
ADREG04L ADREG04H ADREG15L ADREG15H ADREG26L ADREG26H ADREG37L ADREG37H B0CS B1CS B2CS
PG0REG PG1REG PG01CR SC0BUF SC0CR SC0MOD BR0CR SC1BUF SC1CR SC1MOD BR1CR ODE
CKOCR SYSCR0 SYSCR1 INTE0AD INTE45 INTE67 INTET10 INTEPW10 INTET54 INTET76 INTES0 INTES1
TREG4L TREG4H TREG5L TREG5H CAP1L CAP1H CAP2L CAP2H T4MOD T4FFCR T45CR
WDMOD WDCR ADMOD1 ADMOD2
IIMC DMA0V DMA1V DMA2V DMA3V
Note:
Do not access addresses which do not have register names allocated.
93CS40-222
2004-02-10
TMP93CS40/TMP93CS41
(1) I/O port Symbol
P0
Name Address
Port0 00H
7
P07
6
P06
5
P05
4
P04
3
P03
2
P02
1
P01
0
P00
P17 P1 Port1 01H 0 P27 P2 Port2 06H 0 P37 P3 Port 3 07H 1 P4 Port4 0CH
P16
0 P26
0 P36
1
R/W Input mode Undefined P15 P14 P13 R/W Input mode 0 0 0 P25 P24 P23 *R/W (Note 3) Input mode 0 0 0 P35 P34 P33 *R/W (Note 3) Input mode 1 1 1
P12
P11
P10
0 P22
0 P21
0 P20
0 P32
0 P31
0
P30 (Note 1)
1 P42
P57 P5 Port5 0DH P67 P6 Port6 12H 1 P7 Port7 13H
P56
P55
P54
P53
0 P52
Output mode 1 1 P41 P40 *R/W (Note 3) Input mode 1 1 P51 P50
P66
P65
1
1
R Input mode P64 P63 *R/W (Note 3) Input mode 1 1 P73
P62
P61
P60
P87 P8 Port8 18H 1 P97 R/W Output mode 1 PA7
P86
P85
P9
Port9 (Note2)
19H
1 P96 R/W Output mode 1 PA6
1 P95
1 P84 P83 *R/W (Note 3) Input mode 1 1 1 P94 P93 P92 *R/W (Note 3) Input mode 1 PA4 1 PA3
1 1 P72 P71 *R/W (Note 3) Input mode 1 1 P82 P81
1 P70
1 P80
1 P91
1 P90
1 PA5
1 PA2
1 PA1
1 PA0
PA
PortA
1EH
R/W Input mode 1
Note 1: When P30 pin is defined as RD signal output mode (P30F = 1), clearing the output latch register P30 to "0" outputs the RD strobe from P30 pin for PSRAM, even when the internal address is accessed. If the output latch register P30 remains "1", the RD strobe is output only when the external address is accessed. Note 2: Port 96, 97 is also used as XT1, XT2. Therefore these pins are open-drain output type. Read/Write R/W: R: W: Either read or write is possible Only read is possible Only write is possible
Prohibit RMW: Prohibit read-modify-write. (Prohibit RES/SET/TSET/CHG/STCF/ANDCF/ORCF/XORCF instruction.) Note 3: *R/W: Read-modify-write is prohibited when controlling the PU/PD resistors.
93CS40-223
2004-02-10
TMP93CS40/TMP93CS41
(2) I/O port control (1/2) Symbol
P0CR
Name Address
Port 0 control 02H (Prohibit RMW) 04H (Prohibit RMW) 05H (Prohibit RMW) 08H (Prohibit RMW) 09H (Prohibit RMW) 0AH (Prohibit RMW) 0BH (Prohibit RMW)
7
P07C 0 P17C
6
P06C 0 P16C 0 P16F 0 P26C 0 P26F 0 P36C 0 P36F W 0 0: Port 1: R / W
5
P05C 0 P15C 0 P15F 0 P25C 0 P25F 0 P35C W 0 0: Input P35F 0
4
P04C W 0 P14C W 0 P14F W 0 P24C W 0 P24F W 0 P34C 0 1: Output P34F 0
3
P03C 0 P13C 0 P13F 0 P23C 0 P23F 0 P33C 0
2
P02C 0 P12C 0 P12F 0 P22C 0 P22F 0 P32C 0 P32F 0 0: Port 1: HWR P42C
1
P01C 0 P11C 0 P11F 0 P21C 0 P21F 0
0
P00C 0 P10C 0 P10F 0 P20C 0 P20F 0
0: Input 1: Output (When external access, set as AD7 to AD0 and cleared to 0.)
P1CR
Port 1 control
0 P17F
<>
P1FC
Port 1 function
0 P27C
P1FC/P1CR = 00: Input 01: Output 10: AD15 to AD8 11: A15 to A8
P2CR
Port 2 control
0 P27F
<>
P2FC
Port 2 function
0 P37C
P2FC/P2CR = 00: Input 01: Output 10: A7 to A0 11: A23 to A16
P3CR
Port 3 control
0 P37F
P31F W 0 0: Port 1: WR P41C W 0
P30F 0 0: Port 1: RD P40C 0
P3FC
Port 3 function
0 0: Port 1: RAS
0: Port 0: Port 1: BUSAK 1: BUSRQ
P4CR
Port 4 control
0EH (Prohibit RMW) 10H (Prohibit RMW)
0 0: Input P42F 0 0: Port
1: Output P41F W 0 0 1: CS / CAS P40F
P4FC
Port 4 function
Note: With the TMP93CS41, which requires an external ROM, port 0 functions as AD0 to AD7; port 1, AD8 to AD15 or A8 to A15; P30, the RD signal; P31, the WR signal, regardless of the values set in P0CR, P1CR, P1FC, P30F, and P31F.
93CS40-224
2004-02-10
TMP93CS40/TMP93CS41
I/O port control (2/2) Symbol
P6CR
Name Address
Port 6 control 14H (Prohibit RMW) 15H (Prohibit RMW)
7
P67C 0
6
P66C 0
5
P65C 0
4
P64C W 0 0: Input
3
P63C 0 1: Output P73C
2
P62C 0 P72C W 0 0: Input P62F 0 0: Port P72F W 0 0: Port 1: TO2 P82C 0 P92C W 0 P82F W 0 0: Port 1: TO4 P92F W 0 0: Port 1: SCLK0 PA2C
1
P61C 0 P71C 0 1: Output P61F 0 1: PG0 output P71F 0 0: Port 1: TO1 P81C 0 P91C 0
0
P60C 0 P70C 0 P60F 0
P7CR
Port 7 control
0 P67F P66F 0 0: Port P65F 0 1: PG1 output P73F P64F W 0 0 0 P63F
P6FC
Port 6 function
16H (Prohibit RMW) 17H (Prohibit RMW)
P7FC
Port 7 function
0 0: Port 1: TO3 P87C P86C 0 P96C W 1 P86F 0 0 0: Input W 0 0: Port 1: TO6 P95F W 0 0: Port 1: SCLK1 PA7C PA6C PA5C PA4C W 0 0: Input 1: Output 0 1: Output P83F W 0 0: Port 1: TO5 P93F W 0 0: Port 1: TXD1 PA3C P85C 0 P95C P84C W 0 P97C 0 0: Input P94C W 1 0 1: Output P93C P83C
P80C 0 P90C 0
P8CR
Port 8 control
1AH (Prohibit RMW) 1BH (Prohibit RMW) 1CH (Prohibit RMW)
P9CR
Port 9 control
P8FC
Port 8 function
P90F W 0 0: Port 1: TXD0 PA1C PA0C
P9FC
Port 9 function
1DH (Prohibit RMW)
PACR
Port A control
1FH (Prohibit RMW)
93CS40-225
2004-02-10
TMP93CS40/TMP93CS41
(3) Timer control (1/3) Symbol Name Address 7
PRRUN R/W TRUN Timer control 20H 0 0 0 0
6
5
T5RUN
4
T4RUN
3
P1RUN R/W
2
P0RUN 0
1
T1RUN 0
0
T0RUN 0
Prescaler and timer run/stop control 0: Stop and clear 1: Run (Count up) 22H (Prohibit RMW) 23H (Prohibit RMW) T10M1 T10M0 0 PWMM1 0 00: - 01: 26 - 1 10: 27 - 1 11: 28 - 1 - W Undefined - W Undefined PWMM0 W 24H (Prohibit RMW) 0 0 0 0 0 00: TI0 input 01: T1 10: T4 11: T16 TFF1IE 0 1: TFF1 invert enable TFF1IS 0 0: Inverted by timer 0 R/W 1 0 00: 8-bit timer 01: 16-bit timer 10: 8-bit PPG 11: 8-bit PWM 00: TO0TRG 01: T1 10: T16 11: T256 TFF1C1 W 1 00: Invert TFF1 01: Set TFF1 10: Clear TFF1 11: Don't care - 26H (R)/W (Can read double buffer values.) Undefined - 27H FF2RD R - TFF2 output value DB2EN 0 (R)/W (Can read double buffer values.) Undefined PWM0INT PWM0M 0 0 T2CLK1 W 0 00: P1 01: P4 10: P16 11: Don't care T3CLK1 W 0 0 0 0 00: P1 01: P4 10: P16 11: Don't care 0 0 00: 26 - 1 01: 27 - 1 10: 28 - 1 11: Don't care 0 1: Double 0: Overflow 0: PWM buffer mode interrupt enable 1: Compare/ 1: Timer mode match
interrupt
TREG0
8-bit timer register 0 8-bit timer register 1 8-bit timer source CLK & mode
TREG1
T1CLK1
T1CLK0
T0CLK1
T0CLK0
TMOD
PWM
DBEN 8-bit timer flip-flop control R/W 0 25H 1: Double buffer enable
TFF1C0
TFFCR
TREG2
PWM timer register 2 PWM timer register 3
TREG3
T2CLK0 0
PWM0S1 0
PWM0S0 0
P0MOD
PWM0 mode
28H (Prohibit RMW)
1: Double 0: Overflow 0: PWM mode buffer interrupt enable 1: Compare/ 1: Timer mode match
interrupt
00: 26 - 1 01: 27 - 1 10: 28 - 1 11: Don't care PWM1S1 PWM1S0
FF3RD R PWM1 mode 29H (Prohibit RMW) - TFF3 output value
DB3EN
PWM1INT PWM1M
T3CLK0
P1MOD
93CS40-226
2004-02-10
TMP93CS40/TMP93CS41
Timer control (2/3) Symbol Name Address 7
FF3C1 W 1 PWM flip-flop control 1 0 00: Don't care 01: Set TFF3 10: Clear TFF3 11: Don't care
6
FF3C0
5
R/W
4
3
FF2C1 W 1
2
FF2C0 1
1
R/W 0
0
FF3TRG1 FF3TRG0 0
FF2TRG1 FF2TRG0 0
PFFCR
2AH
00: Prohibit TFF3 invert 01: Invert if matched 10: Set if matched; clear if overflow 11: Clear if matched; set if overflow - W
00: Don't care 01: Set TFF2 10: Clear TFF2 11: Don't care
00: Prohibit TFF2 invert 01: Invert if matched 10: Set if matched; clear if overflow 11: Clear if matched; set if overflow
TREG4L
16-bit timer register 4 low
30H (Prohibit RMW) 31H (Prohibit RMW) 32H (Prohibit RMW) 33H (Prohibit RMW) 34H
Undefined - W Undefined - W Undefined - W Undefined - R Undefined -
16-bit timer TREG4H register 4 high TREG5L 16-bit timer register 5 low
16-bit timer TREG5H register 5 high CAP1L Capture register 1 low Capture register 1 high Capture register 2 low Capture register 2 high
CAP1H
35H
R Undefined -
CAP2L
36H
R Undefined -
CAP2H
37H CAP2T5 R/W EQ5T5 CAP1IN W
R Undefined CAP12M1 CAP12M0 0 0 Capture timing 00: Disable 01: T14 T15 10: T14 T14 11: TFF1 TFF1 CLE R/W 0 1: UC4 clear enable 0 0 Source clock 00: T14 01: T1 10: T4 11: T16 T4CLK1 T4CLK0
T4MOD
16-bit timer 4 source CLK and mode
38H
0 0 1 0: SoftTFF5 INV TRG ware 0: TRG disable capture 1: TRG enable 1: Don't Inverted Inverted care when the when the UC value up counter is latched matches to CAP2 TREG5 TFF5C1 W TFF5C0 CAP2T4 0
CAP1T4 R/W
EQ5T4
EQ4T4 0
TFF4C1 W
TFF4C0
T4FFCR
16-bit timer 4 flip-flop control
39H
1 1 00: Invert TFF5 01: Set TFF5 10: Clear TFF5 11: Don't care
Inverted when the UC value is latched to CAP2
0 0 TFF4 invert trigger 0: Trigger disable 1: Trigger enable Inverted Inverted when the when the UC value UC value is latched matches TREG5 to CAP1
Inverted when the UC value matches TREG4
1 1 00: Invert TFF4 01: Set TFF4 10: Clear TFF4 11: Don't care
93CS40-227
2004-02-10
TMP93CS40/TMP93CS41
Timer control (3/3) Symbol Name Address 7
QCU R/W 0 T45CR T4, T5 control 3AH Watchdog /warm-up timer control 0 PG1 shift trigger
1: Timer 5
6
5
4
3
PG1T
2
PG0T R/W 0 PG0 shift trigger
1: Timer 4
1
DB6EN 0 1: Double buffer enable Double buffer of TREG6
0
DB4EN 0
0: Timer 0, 1 0: Timer 0, 1
Double buffer of TREG4
TREG6L
16-bit timer register 6 low
40H (Prohibit RMW) 41H (Prohibit RMW) 42H (Prohibit RMW) 43H (Prohibit RMW) 44H
- W Undefined - W Undefined - W Undefined - W Undefined - R Undefined -
16-bit timer TREG6H register 6 high TREG7L 16-bit timer register 7 low
16-bit timer TREG7H register 7 high CAP3L Capture register 3 low Capture register 3 high Capture register 4 low Capture register 4 high
CAP3H
45H
R Undefined -
CAP4L
46H
R Undefined -
CAP4H
47H CAP3IN W
R Undefined CAP34M1 CAP34M0 0 0 CLE R/W 0 1: UC5 clear enable 0 Source clock 00: T16 01: T1 10: T4 11: T16 TFF6C1 W 0 0 1 1 00: Invert TFF6 01: Set TFF6 10: Clear TFF6 11: Don't care TFF6C0 0 Capture timing 00: Disable 01: T16 T17 10: T16 T16 11: TFF1 TFF1 CAP3T6 R/W 0 0 TFF6 invert trigger 0: Trigger disable 1: Trigger enable Inverted Inverted when when the UC the UC value value is matches latched TREG7 to CAP3 EQ7T6 T5CLK1 T5CLK0
T5MOD
16-bit timer 5 source CLK and mode
1 48H 0: Soft capture 1: Don't care CAP4T6
EQ6T6
T5FFCR
16-bit timer 5 flip-flop control
49H Inverted when the UC value is latched to CAP4
Inverted when the UC value matches TREG6
93CS40-228
2004-02-10
TMP93CS40/TMP93CS41
(4) Pattern generator Symbol
PG0REG
Name
PG0 register PG1 register
Address
4CH (Prohibit RMW) 4DH (Prohibit RMW)
7
PG03 0 PG13 0 PAT1 0
6
PG02 W 0 PG12 W 0 CCW1 0
5
PG01 0 PG11 0 PG1M 0
4
PG00 0 PG10 0 PG1TE R/W 0
3
SA03
2
SA02 R/W
1
SA01
0
SA00
Undefined SA13 SA12 R/W Undefined PAT0 0 CCW0 0 PG0M 0 PG0TE 0 PG0 trigger input enable 1: Enable SA11 SA10
PG1REG
PG01CR
PG0, 1 control
4EH
0: 8-bit write 1: 4-bit write
0: Normal 0: 4-bit rotation step 1: Reverse 1: 8-bit rotation step
PG1 0: 8-bit trigger write input 1: 4-bit enable write 1: Enable
0: Normal 0: 4-bit rotation step 1: Reverse 1: 8-bit rotation step
(5) Watchdog timer Symbol Name Address 7
WDTE 1 WDMOD Watchdog timer mode 5CH 1: WDT enable
6
WDTP1 0 00: 2 /fSYS 01: 217/fSYS 10: 219/fSYS 11: 221/fSYS
15
5
WDTP0 0
4
WARM 0 Warm-up time
0: 2 /inputted frequency 1: 2 /inputted frequency
16 14
3
HALTM1 R/W 0
2
HALTM0 0
1
RESCR 0
1: Connect
0
DRVE 0
Standby mode 00: RUN mode 01: STOP mode 10: IDLE1 mode 11: IDLE2 mode -
1: Drive the pin in WDT out STOP to reset mode pin
internally
WDCR
Watchdog timer control register
5DH
W - B1H: WDT disable code 4EH: WDT clear code
93CS40-229
2004-02-10
TMP93CS40/TMP93CS41
(6) Serial channel Symbol Name Address
50H
7
RB7 TB7
6
RB6 TB6
5
RB5 TB5
4
RB4 TB4
3
RB3 TB3
2
RB2 TB2
1
RB1 RB1
0
RB0 TB0
Serial SC0BUF channel 0 buffer
R (Receiving)/W (Transmission) Undefined RB8 R EVEN R/W 0 0 1: Parity enable PE OERR 0 Overrun PERR 0 1: Error Parity Framing 1: SCLK0 RXE 0 WU R/W 0 SM1 SM0 SC1 FERR 0 SCLKS R/W 0 0: SCLK0 0 1: Input SCLK0 pin SC0 IOC R (Cleared to 0 by reading)
SC0CR
Serial channel 0 control
Undefined 51H
Receiving Parity data bit8 0: Odd 1: Even TB8 CTSE 0 1: CTS enable
Serial SC0MOD channel 0 mode
Undefined 52H
Transmission data bit8
1: Receive 1: Wake enable up enable BR0CK1 0 BR0CK0
0 0 00: I/O Interface 01: UART 7 bits 10: UART 8 bits 11: UART 9 bits BR0S3 R/W 0 BR0S2 0
0 0 00: TO0 trigger 01: Baud rate generator 10: Internal clock 1 11: Don't care BR0S1 0 BR0S0 0
- R/W BR0CR Baud rate control 53H 0 Always fixed to 0 RB7 TB7 54H RB6 TB6
Serial SC1BUF channel 1 buffer
0 00: T0 01: T2 10: T8 11: T32 RB5 RB4 TB5 TB4
Set frequency divisor 0 to F ("1" prohibited) RB3 TB3 RB2 TB2 RB1 RB1 RB0 TB0
R (Receiving)/W (Transmission) Undefined RB8 R EVEN R/W 0 0 1: Parity enable PE OERR 0 Overrun PERR 0 1: Error Parity Framing 1: SCLK1 RXE 0 WU R/W 0 SM1 SM0 SC1 FERR 0 SCLKS R/W 0 0:SCLK1 0 1: Input SCLK1 pin SC0 IOC R (Cleared to 0 by reading)
SC1CR
Serial channel 1 control
Undefined 55H
Receiving Parity data bit8 0: Odd 1: Even TB8 - 0 Always fixed to 0
Serial SC1MOD channel 1 mode
0 56H
Transmission data bit8
1: Receive 1: Wake enable up enable BR1CK1 0 00: T0 01: T2 10: T8 11: T32 BR1CK0 0
0 0 00: I/O interface 01: UART 7 bits 10: UART 8 bits 11: UART 9 bits BR1S3 R/W 0 0 BR1S2
0 0 00: TO0 Trigger 01: Baud rate generator 10: Internal clock 1 11: Don't care BR1S1 0 BR1S0 0
- R/W BR1CR Baud rate control 57H 0 Always fixed to 0
Set frequency divisor 0 to F ("1" prohibited) ODE1 ODE0 R/W 0 1: P90 Open drain
ODE
Serial opendrain enable
58H
0 1: P93 Open drain
93CS40-230
2004-02-10
TMP93CS40/TMP93CS41
(7) AD converter control Symbol Name Address 7
EOCF 5EH R 0 1: End VREFON AD ADMOD2 mode register 2 R/W 5FH 1
Ladder resistance switch ON/OFF
6
ADBF 0 1: Busy
5
REPET R/W 0 SPEED1 0
4
SCAN 0 SPEED0 0
3
2
ADS R/W 0 1: Start ADCH2 0
1
0
AD ADMOD1 mode register 1
1: Repeat 1: Scan R/W Speed select
ADCH1 R/W 0
ADCH0 0
Analog input channel select
(Note 1) AD result AD register REG04L 0/4 low AD result AD register REG04H 0/4 high (Note 1) AD result AD register REG15L 1/5 low AD result AD register REG15H 1/5 high (Note 1) AD result AD register REG26L 2/6 low AD result AD register REG26H 2/6 high (Note 1) AD result AD register REG37L 3/7 low AD result AD register REG37H 3/7 high
ADR01 60H ADR09 61H ADR11 62H ADR19 63H ADR21 64H ADR29 65H ADR31 66H ADR39 67H R R R R
ADR00
Undefined ADR08 ADR07 ADR06 R Undefined ADR10 ADR05 ADR04 ADR03 ADR02
Undefined ADR18 ADR17 ADR16 R Undefined ADR20 ADR15 ADR14 ADR13 ADR12
Undefined ADR28 ADR27 ADR26 R Undefined ADR30 ADR25 ADR24 ADR23 ADR22
Undefined ADR38 ADR37 ADR36 R Undefined ADR35 ADR34 ADR33 ADR32
Note 1: Data to be stored in AD conversion result register low are the lower 2 bits of the conversion result. The contents of the lower 6 bits of this register are always read as "1".
MSB Converted data of channel "X"
LSB
9876543210
ADREGXH 76543210
ADREGXL 76543210
This is "1" when this is read.
93CS40-231
2004-02-10
TMP93CS40/TMP93CS41
(8) Interrupt control (1/2) Symbol Name Address
70H (Prohibit RMW) 71H (Prohibit RMW) 72H (Prohibit RMW) 73H (Prohibit RMW) 74H (Prohibit RMW) 75H (Prohibit RMW) 76H (Prohibit RMW) 77H (Prohibit RMW) 78H (Prohibit RMW)
7
IADC R/W 0
6
INTAD IADM2 0 INT5 I5M2 0 INT7 I7M2 0 IT1M2 0 IPW1M2 0 IT5M2 0 IT7M2 0 INTTX0 ITX0M2 0 INTTX1 ITX1M2 0
5
IADM1 W 0 I5M1 W 0 I7M1 W 0 IT1M1 W 0 IPW1M1 W 0 IT5M1 W 0 IT7M1 W 0 ITX0M1 W 0 ITX1M1 W 0
4
IADM0 0 I5M0 0 I7M0 0 IT1M0 0 IPW1M0 0 IT5M0 0 IT7M0 0 ITX0M0 0 ITX1M0 0
3
I0C R/W 0 I4C R/W 0 I6C R/W 0 IT0C R/W 0 IPW0C R/W 0 IT4C R/W 0 IT6C R/W 0 IRX0C R/W 0 IRX1C R/W 0
2
INT0 I0M2 0 INT4 I4M2 0 INT6 I6M2 0 IT0M2 0 IPW0M2 0 IT4M2 0 IT6M2 0 INTRX0 IRX0M2 0 INTRX1 IRX1M2 0
1
I0M1 W 0 I4M1 W 0 I6M1 W 0 IT0M1 W 0 IPW0M1 W 0 IT4M1 W 0 IT6M1 W 0 IRX0M1 W 0 IRX1M1 W 0
0
I0M0 0 I4M0 0 I6M0 0 IT0M0 0 IPW0M0 0 IT4M0 0 IT6M0
Interrupt INTE0AD enable 0 & AD Interrupt enable 4/5 Interrupt enable 6/7
INTE45
I5C R/W 0 I7C R/W 0
INTE67
Interrupt INTET10 enable timer 1/0 Interrupt INTEPW10 enable PWM 1/0 Interrupt enable INTET54 T register 5/4 Interrupt enable INTET76 T register 7/6 Interrupt enable serial 0 Interrupt enable serial 1
INTT1 (Timer 1) IT1C R/W 0 IPW1C R/W 0 IT5C R/W 0 IT7C R/W 0 ITX0C R/W 0 ITX1C R/W 0
INTT0 (Timer 0)
INTT3 (Timer 3/PWM1)
INTT2 (Timer 2/PWM0)
INTTR5 (TREG5)
INTTR4 (TREG4)
INTTR7 (TREG7)
INTTR6 (TREG6)
INTES0
IRX0M0 0 IRX1M0 0
INTES1
IxxM2
0 0 0 0 1 1 1 1
IxxM1
0 0 1 1 0 0 1 1
IxxM0
0 1 0 1 0 1 0 1
Function (Write)
Prohibit interrupt request. Set interrupt request level to "1". Set interrupt request level to "2". Set interrupt request level to "3". Set interrupt request level to "4". Set interrupt request level to "5". Set interrupt request level to "6". Prohibit interrupt request.
IxxC
0 1
Function (Read)
Indicate no interrupt request. Indicate interrupt request.
Function (Write)
Clear interrupt request flag. - - - - - Don't care - - - - -
93CS40-232
2004-02-10
TMP93CS40/TMP93CS41
Interrupt control (2/2) Symbol Name
DMA 0 request vector DMA 1 request vector DMA 2 request vector DMA 3 request vector
Address
7CH (Prohibit RMW) 7DH (Prohibit RMW) 7EH (Prohibit RMW) 7FH (Prohibit RMW)
7
6
5
4
DMA0V4 0 DMA1V4 0 DMA2V4 0 DMA3V4 0
3
DMA0V3 0 DMA1V3 0 DMA2V3 0 DMA3V3 0
2
DMA0V2 W 0 DMA1V2 W 0 DMA2V2 W 0 DMA3V2 W 0 I0IE W 0
1
DMA0V1 0 DMA1V1 0 DMA2V1 0 DMA3V1 0 I0LE W 0 0: INT0 edge mode 1: INT0 level mode
0
DMA0V0 0 DMA1V0 0 DMA2V0 0 DMA3V0 0 NMIREE W 0
0: Operation even at
NMI
Micro DMA0 start vector
DMA0V
Micro DMA1 start vector
DMA1V
Micro DMA2 start vector
DMA2V
Micro DMA3 start vector
DMA3V
IIMC
Interrupt input mode control
7BH (Prohibit RMW)
0: INT0 input enable
rising edge
93CS40-233
2004-02-10
TMP93CS40/TMP93CS41
(9) Chip select/wait controller Symbol Name Address 7
B0E Block 0 CS/WAIT control register W 68H (Prohibit RMW) 0 1: B0CS master bit B1E Block 1 CS/WAIT control register W 69H (Prohibit RMW) 0 1: B1CS master bit B2E Block 2 CS/WAIT control register W 6AH (Prohibit RMW) 1 1: B2CS master bit
6
5
B0CAS W 0 0: CS0 1: CAS0
4
B0BUS W 0 0: 16-bit bus 1: 8-bit bus B1BUS W 0 0: 16-bit bus 1: 8-bit bus B2BUS W 0 0: 16-bit bus 1: 8-bit bus
3
B0W1 W 0
2
B0W0 W 0
1
B0C1 W 0
0
B0C0 W 0
B0CS
00: 2 waits 01: 1 wait 10: (1 + n) waits 11: 0 waits B1W1 W 0 B1W0 W 0
00: 7F00H to 7FFFH 01: 400000H to 10: 800000H to 11: C00000H to B1C1 W 0 B1C0 W 0
B1CAS W 0 0: CS1 1: CAS1
B1CS
00: 2 waits 01: 1 wait 10: (1 + n) waits 11: 0 waits B2W1 W 0 B2W0 W 0
00: 880H to 7FFFH 01: 400000H to 10: 800000H to 11: C00000H to B2C1 W 0 B2C0 W 0
B2CAS W 0 0: CS2 1: CAS2
B2CS
00: 2 waits 01: 1 wait 10: (1 + n) waits 11: 0 waits
00: 8000H to 01: 400000H to 10: 800000H to 11: C00000H to
Note: After reset, only "Block 2" is set to enable.
93CS40-234
2004-02-10
TMP93CS40/TMP93CS41
(10) Clock control Symbol Name Address 7 6 5 4 3
SCOSEL 0 006DH SCOUT select 0: fFPH 1: fSYS
2
SCOEN R/W 0 SCOUT output control 0: I/O port 1: SCOUT output WUEF 0
Warm-up timer 0 Write: Don't care 1 Write: Start timer 0 Read: End warm up 1 Read: Continue warm up
1
ALEEN
0
CLKEN
CKOCR
Clock output control register
0/1 (Note 1) 0/1 (Note 1) ALE pin control 0:High-Z output 1: ALE output PRCK1 0
00: fFPH 01: fs 10: fc/16 11: (Reserved)
CLK pin control 0:High-Z output 1: CLK output PRCK0 0
XEN 1
Highfrequency oscillator (fc)
XTEN 0
Lowfrequency oscillator (fs) 0: Stop
RXEN 1
Highfrequency after release of 0: Stop
RXTEN 0
Lowfrequency after release of
RSYSCK R/W 0
Selected clock after Stop mode 0: fc
Select prescaler clock
SYSCR0
System clock control register 0
oscillator (fc) oscillator (fs) Release of
006EH
0: Stop
1: Oscillation 1: Oscillation STOP mode STOP mode 1: fs 1: Oscillation 0: Stop 1: Oscillation
SYSCK 0
Select
GEAR2 R/W 1
000: fc 001: fc/2 010: fc/4 011: fc/8 100: fc/16
GEAR1 0
GEAR0 0
Select gear value of high frequency (fc)
SYSCR1
System clock control register 1
system clock
006FH
0: fc 1: fs (Note2)
101: (Reserved) 110: (Reserved) 111: (Reserved)
Note 1:
The value after reset of , is as follows: TMP93CS40: 0 (High impedance output) TMP93CS41: 1 (CLK or ALE output) However, during reset the CLK pin is pulled up internally on both models. The high-frequency oscillator will be enabled when SYSCR1 is set to 0 regardless of the value of SYSCR0. The low-frequency oscillator will be enabled when SYSCR1 is set to 1 regardless of the value of SYSCR0.
Note 2:
93CS40-235
2004-02-10
TMP93CS40/TMP93CS41
6.
Port Section Equivalent Circuit Diagram
* Reading the circuit diagram Basically, the gate symbols written are the same as those used for the standard CMOS logic IC [74HCXX] series. The dedicated signal is described below. Stop: This signal becomes active "1" when the HALT mode setting register is set to the STOP mode and the CPU executes the HALT instruction. When the drive enable bit [DRVE] is set to "1", however, stop remains at "0". * The input protection resistance ranges from several tens of ohms to several hundreds of ohms. P0 (AD0 to AD7), P1 (AD8 to AD15, A8 to A15), P2 (A16 to A23, A0 to A7)
VCC Output data P-ch
Output enable Stop
N-ch
Input data N-ch Input enable
I/O Programmable pull-down resistance (only port 2)
P30 ( RD ), P31 ( WR )
VCC
Output data
Output
Stop
93CS40-236
2004-02-10
TMP93CS40/TMP93CS41
P32 to P37, P40 to P41, P6, P7, P80 to P86, P91 to P92, P94 to P95, PA
VCC Output data
VCC Output enable Stop
Programmable pull-up resistance (not exist in port A) I/O
Input data
Input enable
P42 ( CS2 , CAS2 )
VCC Output data
Output enable Stop Input data I/O Programmable pull-down resistance
Input enable
P5 (AN0 to AN7)
Analog input channel select Analog input Input
Input data
Input enable
93CS40-237
2004-02-10
TMP93CS40/TMP93CS41
P87 (INT0)
VCC Output data
Output enable Stop
VCC
Programmable pull-up resistance I/O
Input data Schmitt
P90 (TXD0), P93 (TXD1)
VCC Output data
Open-drain enable Stop
VCC
Programmable pull-up resistance I/O
Input data
Input enable
P96 (XT1), P97 (XT2)
Clock Input enable Oscillator Input data P97 (XT2)
Output data Output enable
Input enable
Input data Output data Output enable P96 (XT1)
Stop Low-frequency oscillation enable
93CS40-238
2004-02-10
TMP93CS40/TMP93CS41
NMI
NMI Schmitt Input
WDTOUT
WDTOUT Output
CLK
VCC P-ch VCC
Output enable Internal CLK
Output Stop N-ch Internal reset
Test circuit
Input enable
EA
Input data Input
AM8/ AM16
Input data Input
ALE
VCC Internal ALE P-ch Output Output enable N-ch
93CS40-239
2004-02-10
TMP93CS40/TMP93CS41
RESET
VCC
Reset Schmitt
Input
WDTOUT Reset enable
X1, X2
Clock Oscillator X2 P-ch N-ch
High-frequency oscillation enable X1
VREFH, VREFL
VREFON P-ch VREFH
String resistance
VREFL
93CS40-240
2004-02-10
TMP93CS40/TMP93CS41
7.
Points of Note and Restrictions
(1) Notation 1. 2. How a built-in I/O register is denoted: Register symbol e.g.) TRUN ... Bit T0RUN of register TRUN Read-modify-write instruction An instruction in which the CPU reads data from memory and writes the data to the same memory location in one instruction. Example 1: Example 2: * SET INC 3, (TRUN) ... Set bit3 of TRUN 1, (100H) ... Increment the data at 100H
A sample read-modify-write instructions using the TLCS-900 Exchange instruction EX (mem), R Arithmetic operation ADD (mem), R/# SUB (mem), R/# INC #3, (mem) Logic operation AND (mem), R/# XOR (mem), R/# Bit manipulation STCF #3/A, (mem) SET #3, (mem) TSET #3, (mem) Rotate, Shift RLC (mem) RL (mem) SLA (mem) SLL (mem) RLD (mem) 3. fc, fFPH, fSYS, one state
ADC (mem), R/# SBC (mem), R/# DEC #3, (mem) OR (mem), R/#
RES #3, (mem) CHG #3, (mem) RRC RR SRA SRL RRD (mem) (mem) (mem) (mem) (mem)
The clock frequency input from pins X1 and X2 is called fc, the clock selected by SYSCR is called fFPH, and the clock frequency given by fFPH divided by 2 is called fSYS. One cycle of fSYS is called one state.
93CS40-241
2004-02-10
TMP93CS40/TMP93CS41
(2) Points to note 1. 2. 3.
EA , AM8/ AM16 pin
Fix these pins to VCC or GND unless changing voltage. TEST1, TEST2 pin Connect the TEST1 pin with the TEST2 pin. Do not connect to any other pins. Reserved area in memory space The 256 bytes of memory between FFFF00H and FFFFFFH cannot be used because they are reserved. Standby mode (IDLE1) When IDLE1 mode (Oscillator operation only) is used, set TRUN to 0 to stop the prescaler before the HALT instruction is executed. Warm-up counter The warm-up counter operates when STOP mode is released even if the system is using an external oscillator. As a result, a time equivalent warm-up time elapses from input of the release request to output of the system clock. Micro DMA (DRAM refresh mode) When the bus is released ( BUSAK = 0). DRAM refresh cannot be performed because the micro DMA cannot access the bus. Programmable pull-up/pull-down resistance The programmable pull-up/pull-down resistors can be turned ON/OFF by the program when the ports are used as input ports. When the ports are used as outputs, they cannot be turned ON/OFF by the program. The data registers (e.g., P2, P3, ...) are used for the pull-up/pull-down resistors ON/OFF. Consequently read-modify-write instructions are prohibited. 8. Bus release function Refer to the note about the bus release in 3.5 "Functions of Ports" as it describes the state of the pins when the bus is released. Watchdog timer The watchdog timer starts operation immediately after the reset is released. When the watch dog timer will not be used, disable it.
4.
5.
6.
7.
9.
10. Watchdog timer When the bus is released, neither internal memory nor internal I/O can be accessed. However, the internal I/O continues to operate and hence, the watchdog timer continues to run. Thus, take care when setting the bus release time and the detection timer for the watchdog timer. 11. AD converter The ladder resistor between the VREFH and VREFL pins can be cut by a program to reduce power consumption. When standby mode is used, disable the resistor using the program before the HALT instruction is executed. And set ADMOD2 = "00". 12. CPU (Micro DMA) Only the "LDC cr, r" and "LDC r, cr" instructions can be used to access the control registers in the CPU (like the transfer source address register (DMASn)). 13. POP SR instruction Please execute POP SR instruction during DI condition. 14. Pin states in STOP mode Open-drain output state. Input gate in operation. Set output to "L" or attach pull up on pin so that the input gate stays constant.
93CS40-242
2004-02-10
TMP93CS40/TMP93CS41
15. Releasing the HALT mode by requesting an interruption Usually, interrupts can release all halts status. However, the interrupts ( NMI , INT0) which can release the HALT mode may not be able to do so if they are input during the period CPU is shifting to the HALT mode (for about 3 clocks of fFPH) with IDLE1 or STOP mode (IDLE2/RUN are not applicable to this case). (In this case, an interrupt request is kept on hold internally.) If another interrupt is generated after it has shifted to HALT mode completely, halt status can be released without difficulty. The priority of this interrupt is compared with that of the interrupt kept on hold internally, and the interrupt with higher priority is handled first followed by the other interrupt.
93CS40-243
2004-02-10
8.
Item
TMP93CM40F
TMP93CS40F
TMP93CS41F
TMP93PS40F
TMP93CW40F TMP93CW41F
TMP93PW40F
Built-in ROM
None None
32-Kbyte mask ROM (8000H to FFFFH) 2-Kbyte (0080H to 087FH)
64-Kbyte mask ROM (8000H to 17FFFH)
64-Kbyte OTP (8000H to 17FFFH)
128-Kbyte mask ROM (8000H to 27FFFH)
128-Kbyte OTP (8000H to 27FFFH)
Built-in RAM
4 to 10 MHz 4 to 12.5 MHz
4-Kbyte (0080H to 107FH)
TMP93XX40/41 Different Points
Operation frequency: fc (3 V 10%)
5 V 10% (4 to 20 MHz) 5 V 10% (4 to 20 MHz) 3 V 10% (4 to 12.5 MHz)
ADC operation voltage range
93CS40-244
0.2 VCC 0.3 VCC from 10000H from 18000H from 08000H from 18000H 880H to 7FFFH
Port 5 input level (VIL)
CS2 Mapping area (B2CS < B2C1 to 0 00)
from 28000H
from 08000H
from 28000H
CS1 Mapping area (B1CS < B1C1 to 0 00)
1080H to 7FFFH
TMP93CS40/TMP93CS41
2004-02-10
TMP93CS40/TMP93CS41
9.
Package Dimensions
P-QFP100-1414-0.50 Unit: mm
93CS40-245
2004-02-10
TMP93CS40/TMP93CS41
P-LQFP100-1414-0.50F Unit: mm
93CS40-246
2004-02-10


▲Up To Search▲   

 
Price & Availability of TMP93CS40

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X